Search code examples
gdalmap-projections

GDAL doesnt recognize bipolar conic western hemisphere projection


I'm having trouble with a particular projection. It seems supported within proj4 (http://proj4.org/usage/operations/projections/bipc.html) But when I use it within gdal it's as if it doesnt exist:

gdalsrsinfo:

gdalsrsinfo -o proj4 "+proj=bipc +ns"

yields

failed to load SRS definition

gdalwarp:

gdalwarp -overwrite -s_srs EPSG:4326 -t_srs "+proj=bipc +ns" -of GTiff in.tiff out.tiff

yields

ERROR 1: Translating source or target SRS failed: +proj=bipc +ns

Also, running proj -lp lists it bipc : Bipolar conic of western hemisphere.

These commands work fine for me with more common (re)projections, and I've tried this on GDAL 1.11.5 and 2.2.2.

Why isn't this projection working/how do I get it recognized?


Solution

  • GDAL does not support all projections. You can make a list of these with Python:

    #!/usr/bin/env python
    from osgeo import osr
    from subprocess import Popen, PIPE
    
    osr.UseExceptions()
    
    # Get the list of PROJ.4 projections
    proj = {}
    p = Popen(['proj', '-lp'], stdout=PIPE)
    for line in p.communicate()[0].split('\n'):
        if ':' in line:
            a, b = line.split(':')
            proj[a.strip()] = b.strip()
    
    # Brute force method of testing GDAL's OSR module
    supported = set()
    not_supported = set()
    for k in proj.keys():
        sr = osr.SpatialReference()
        try:
            _ = sr.ImportFromProj4('+proj=' + k)
            supported.add(k)
        except RuntimeError as e:
            not_supported.add(k)
    
    print('{0} total projections, {1} supported, {2} not supported'
          .format(len(proj), len(supported), len(not_supported)))
    print('Supported: ' + ', '.join(sorted(supported)))
    print('Not supported: ' + ', '.join(sorted(not_supported)))
    

    134 total projections, 47 supported, 87 not supported

    Supported: aea, aeqd, bonne, cass, cea, eck1, eck2, eck3, eck4, eck5, eck6, eqc, eqdc, etmerc, gall, geos, gnom, goode, gstmerc, igh, krovak, laea, lcc, merc, mill, moll, nzmg, omerc, ortho, poly, qsc, robin, sinu, somerc, stere, sterea, tmerc, tpeqd, utm, vandg, wag1, wag2, wag3, wag4, wag5, wag6, wag7

    Not supported: airy, aitoff, alsk, apian, august, bacon, bipc, boggs, calcofi, cc, chamb, collg, crast, denoy, euler, fahey, fouc, fouc_s, gins8, gn_sinu, gs48, gs50, hammer, hatano, healpix, imw_p, isea, kav5, kav7, labrd, lagrng, larr, lask, latlon, lcca, leac, lee_os, lonlat, loxim, lsat, mbt_fps, mbt_s, mbtfpp, mbtfpq, mbtfps, mil_os, murd1, murd2, murd3, natearth, nell, nell_h, nicol, nsper, ob_tran, ocea, oea, ortel, pconic, putp1, putp2, putp3, putp3p, putp4p, putp5, putp5p, putp6, putp6p, qua_aut, rhealpix, rouss, rpoly, tcc, tcea, tissot, tpers, ups, urm5, urmfps, vandg2, vandg3, vandg4, vitk1, weren, wink1, wink2, wintri