Exemplo n.º 1
0
def osr_compd_4():

    srs = osr.SpatialReference()
    srs.ImportFromEPSG( 7400 )

    exp_wkt = """COMPD_CS["NTF (Paris) + NGF IGN69 height",
    GEOGCS["NTF (Paris)",
        DATUM["Nouvelle_Triangulation_Francaise_Paris",
            SPHEROID["Clarke 1880 (IGN)",6378249.2,293.4660212936265,
                AUTHORITY["EPSG","7011"]],
            TOWGS84[-168,-60,320,0,0,0,0],
            AUTHORITY["EPSG","6807"]],
        PRIMEM["Paris",2.33722917,
            AUTHORITY["EPSG","8903"]],
        UNIT["grad",0.01570796326794897,
            AUTHORITY["EPSG","9105"]],
        AUTHORITY["EPSG","4807"]],
    VERT_CS["NGF-IGN69 height",
        VERT_DATUM["Nivellement General de la France - IGN69",2005,
            AUTHORITY["EPSG","5119"]],
        UNIT["metre",1,
            AUTHORITY["EPSG","9001"]],
        AXIS["Up",UP],
        AUTHORITY["EPSG","5720"]],
    AUTHORITY["EPSG","7400"]]"""
    wkt = srs.ExportToPrettyWkt() 

    if gdaltest.equal_srs_from_wkt( exp_wkt, wkt ) == 0:
        gdaltest.post_reason( 'did not get expected compound cs for EPSG:7400')
        return 'fail'
    elif exp_wkt != wkt:
        print('warning they are equivalent, but not completely the same')
        print(wkt)

    return 'success'
Exemplo n.º 2
0
def test_osr_compd_4():

    srs = osr.SpatialReference()
    srs.ImportFromEPSG(7400)

    assert srs.Validate() == 0, 'Does not validate'

    exp_wkt = """COMPD_CS["NTF (Paris) + NGF IGN69 height",
    GEOGCS["NTF (Paris)",
        DATUM["Nouvelle_Triangulation_Francaise_Paris",
            SPHEROID["Clarke 1880 (IGN)",6378249.2,293.4660212936265,
                AUTHORITY["EPSG","7011"]],
            TOWGS84[-168,-60,320,0,0,0,0],
            AUTHORITY["EPSG","6807"]],
        PRIMEM["Paris",2.33722917,
            AUTHORITY["EPSG","8903"]],
        UNIT["grad",0.01570796326794897,
            AUTHORITY["EPSG","9105"]],
        AUTHORITY["EPSG","4807"]],
    VERT_CS["NGF-IGN69 height",
        VERT_DATUM["Nivellement General de la France - IGN69",2005,
            AUTHORITY["EPSG","5119"]],
        UNIT["metre",1,
            AUTHORITY["EPSG","9001"]],
        AXIS["Up",UP],
        AUTHORITY["EPSG","5720"]],
    AUTHORITY["EPSG","7400"]]"""
    wkt = srs.ExportToPrettyWkt()

    assert gdaltest.equal_srs_from_wkt(exp_wkt, wkt) != 0, \
        'did not get expected compound cs for EPSG:7400'
Exemplo n.º 3
0
def jpipkak_2():

    return 'skip'

    if gdaltest.jpipkak_drv is None:
        return 'skip'

    
    ds = gdal.Open( 'jpip://216.150.195.220/JP2Server/qb_boulder_pan_byte' )
    if ds is None:
        gdaltest.post_reason( 'failed to open jpip stream.' )
        return 'fail'

    wkt = ds.GetProjectionRef()
    exp_wkt = 'PROJCS["WGS 84 / UTM zone 13N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-105],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32613"]]'
    
    if not gdaltest.equal_srs_from_wkt( exp_wkt, wkt ):
        return 'fail'
    
    target = ds.GetRasterBand(1).GetOverview(3)

    stats = target.GetStatistics(0,1)

    if abs(stats[2] - 43.429) > 1.0 or abs(stats[3]-18.526) > 1.0:
        print( stats )
        gdaltest.post_reason( 'did not get expected mean/stddev' )
        return 'fail'

    return 'success'
Exemplo n.º 4
0
def hfa_verify_dataset_projection(dataset_path, exp_wkt):

    ds = gdal.Open(dataset_path)
    srs_wkt = ds.GetProjectionRef()
    assert gdaltest.equal_srs_from_wkt(exp_wkt, srs_wkt), 'wrong outputProjection'

    ds = None
Exemplo n.º 5
0
def osr_pci_1():

    prj_parms = (0.0, 0.0, 45.0, 54.5, 47.0, 62.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
    srs = osr.SpatialReference()
    srs.ImportFromPCI('EC          E015', 'METRE', prj_parms)

    if abs(srs.GetProjParm(osr.SRS_PP_STANDARD_PARALLEL_1)-47.0)>0.0000005 \
       or abs(srs.GetProjParm(osr.SRS_PP_STANDARD_PARALLEL_2)-62.0)>0.0000005 \
       or abs(srs.GetProjParm(osr.SRS_PP_LATITUDE_OF_CENTER)-54.5)>0.0000005 \
       or abs(srs.GetProjParm(osr.SRS_PP_LONGITUDE_OF_CENTER)-45.0)>0.0000005 \
       or abs(srs.GetProjParm(osr.SRS_PP_FALSE_EASTING)-0.0)>0.0000005 \
       or abs(srs.GetProjParm(osr.SRS_PP_FALSE_NORTHING)-0.0)>0.0000005:
        gdaltest.post_reason('Can not import Equidistant Conic projection.')
        return 'fail'

    expected = 'PROJCS["unnamed",GEOGCS["Unknown - PCI E015",DATUM["Unknown - PCI E015",SPHEROID["Krassowsky 1940",6378245,298.3,AUTHORITY["EPSG","7024"]]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Equidistant_Conic"],PARAMETER["standard_parallel_1",47],PARAMETER["standard_parallel_2",62],PARAMETER["latitude_of_center",54.5],PARAMETER["longitude_of_center",45],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]]'

    if not gdaltest.equal_srs_from_wkt(expected, srs.ExportToWkt()):
        return 'fail'

    pci_parms = srs.ExportToPCI()
    if pci_parms[0] != 'EC          E015' \
       or pci_parms[1] != 'METRE' \
       or pci_parms[2] != prj_parms:
        print(pci_parms)
        gdaltest.post_reason('ExportToPCI result wrong.')
        return 'fail'

    return 'success'
Exemplo n.º 6
0
def test_osr_compd_4():

    srs = osr.SpatialReference()
    srs.ImportFromEPSG(7400)

    assert srs.Validate() == 0, 'Does not validate'

    exp_wkt = """COMPD_CS["NTF (Paris) + NGF IGN69 height",
    GEOGCS["NTF (Paris)",
        DATUM["Nouvelle_Triangulation_Francaise_Paris",
            SPHEROID["Clarke 1880 (IGN)",6378249.2,293.4660212936265,
                AUTHORITY["EPSG","7011"]],
            TOWGS84[-168,-60,320,0,0,0,0],
            AUTHORITY["EPSG","6807"]],
        PRIMEM["Paris",2.33722917,
            AUTHORITY["EPSG","8903"]],
        UNIT["grad",0.01570796326794897,
            AUTHORITY["EPSG","9105"]],
        AUTHORITY["EPSG","4807"]],
    VERT_CS["NGF-IGN69 height",
        VERT_DATUM["Nivellement General de la France - IGN69",2005,
            AUTHORITY["EPSG","5119"]],
        UNIT["metre",1,
            AUTHORITY["EPSG","9001"]],
        AXIS["Up",UP],
        AUTHORITY["EPSG","5720"]],
    AUTHORITY["EPSG","7400"]]"""
    wkt = srs.ExportToPrettyWkt()

    assert gdaltest.equal_srs_from_wkt(exp_wkt, wkt) != 0, \
        'did not get expected compound cs for EPSG:7400'
Exemplo n.º 7
0
def osr_url_test(url, expected_wkt):
    timeout = 10
    socket.setdefaulttimeout(timeout)
    if gdaltest.gdalurlopen(url) is None:
        return 'skip'
    """Depend on the Accepts headers that ImportFromUrl sets to request SRS from sr.org"""
    srs = osr.SpatialReference()
    from osgeo import gdal
    gdal.PushErrorHandler('CPLQuietErrorHandler')
    try:
        srs.ImportFromUrl(url)
    except AttributeError:  # old-gen bindings don't have this method yet
        return 'skip'
    except Exception:
        gdal.PopErrorHandler()
        if gdal.GetLastErrorMsg() == "GDAL/OGR not compiled with libcurl support, remote requests not supported." or \
           gdal.GetLastErrorMsg().find("timed out") != -1:
            return 'skip'
        else:
            gdaltest.post_reason('exception: ' + gdal.GetLastErrorMsg())
            return 'fail'

    gdal.PopErrorHandler()
    if gdal.GetLastErrorMsg() == "GDAL/OGR not compiled with libcurl support, remote requests not supported." or \
       gdal.GetLastErrorMsg().find("timed out") != -1:
        return 'skip'

    if not gdaltest.equal_srs_from_wkt(expected_wkt, srs.ExportToWkt()):
        return 'fail'

    return 'success'
Exemplo n.º 8
0
def osr_url_test(url, expected_wkt):
    timeout =  10
    socket.setdefaulttimeout(timeout)
    if gdaltest.gdalurlopen(url) is None:
        return 'skip'

    """Depend on the Accepts headers that ImportFromUrl sets to request SRS from sr.org"""
    srs = osr.SpatialReference()
    import gdal
    gdal.PushErrorHandler( 'CPLQuietErrorHandler' ) 
    try:
        srs.ImportFromUrl( url )
    except AttributeError: # old-gen bindings don't have this method yet
        return 'skip'
    except Exception:
        gdal.PopErrorHandler()
        if gdal.GetLastErrorMsg() == "GDAL/OGR not compiled with libcurl support, remote requests not supported." or \
           gdal.GetLastErrorMsg().find("timed out") != -1:
            return 'skip'
        else:
            gdaltest.post_reason( 'exception: ' + gdal.GetLastErrorMsg() )
            return 'fail'

    gdal.PopErrorHandler()
    if gdal.GetLastErrorMsg() == "GDAL/OGR not compiled with libcurl support, remote requests not supported." or \
       gdal.GetLastErrorMsg().find("timed out") != -1:
        return 'skip'

    if not gdaltest.equal_srs_from_wkt( expected_wkt,
                                        srs.ExportToWkt() ):
        return 'fail'

    return 'success'
Exemplo n.º 9
0
def hfa_verify_dataset_projection(dataset_path, exp_wkt):

    ds = gdal.Open(dataset_path)
    srs_wkt = ds.GetProjectionRef()
    assert gdaltest.equal_srs_from_wkt(exp_wkt, srs_wkt), 'wrong outputProjection'

    ds = None
Exemplo n.º 10
0
def jpipkak_2():

    return 'skip'

    # pylint: disable=unreachable
    if gdaltest.jpipkak_drv is None:
        return 'skip'

    ds = gdal.Open('jpip://216.150.195.220/JP2Server/qb_boulder_pan_byte')
    if ds is None:
        gdaltest.post_reason('failed to open jpip stream.')
        return 'fail'

    wkt = ds.GetProjectionRef()
    exp_wkt = 'PROJCS["WGS 84 / UTM zone 13N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-105],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32613"]]'

    if not gdaltest.equal_srs_from_wkt(exp_wkt, wkt):
        return 'fail'

    target = ds.GetRasterBand(1).GetOverview(3)

    stats = target.GetStatistics(0, 1)

    if abs(stats[2] - 43.429) > 1.0 or abs(stats[3] - 18.526) > 1.0:
        print(stats)
        gdaltest.post_reason('did not get expected mean/stddev')
        return 'fail'

    return 'success'
Exemplo n.º 11
0
def osr_pci_1():

    prj_parms = (0.0, 0.0, 45.0, 54.5, 47.0, 62.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
    srs = osr.SpatialReference()
    srs.ImportFromPCI('EC          E015', 'METRE', prj_parms )

    if abs(srs.GetProjParm(osr.SRS_PP_STANDARD_PARALLEL_1)-47.0)>0.0000005 \
       or abs(srs.GetProjParm(osr.SRS_PP_STANDARD_PARALLEL_2)-62.0)>0.0000005 \
       or abs(srs.GetProjParm(osr.SRS_PP_LATITUDE_OF_CENTER)-54.5)>0.0000005 \
       or abs(srs.GetProjParm(osr.SRS_PP_LONGITUDE_OF_CENTER)-45.0)>0.0000005 \
       or abs(srs.GetProjParm(osr.SRS_PP_FALSE_EASTING)-0.0)>0.0000005 \
       or abs(srs.GetProjParm(osr.SRS_PP_FALSE_NORTHING)-0.0)>0.0000005:
        gdaltest.post_reason('Can not import Equidistant Conic projection.')
        return 'fail'

    expected = 'PROJCS["unnamed",GEOGCS["Unknown - PCI E015",DATUM["Unknown - PCI E015",SPHEROID["Krassowsky 1940",6378245,298.3,AUTHORITY["EPSG","7024"]]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Equidistant_Conic"],PARAMETER["standard_parallel_1",47],PARAMETER["standard_parallel_2",62],PARAMETER["latitude_of_center",54.5],PARAMETER["longitude_of_center",45],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]]'

    if not gdaltest.equal_srs_from_wkt( expected, srs.ExportToWkt() ):
        return 'fail'

    pci_parms = srs.ExportToPCI()
    if pci_parms[0] != 'EC          E015' \
       or pci_parms[1] != 'METRE' \
       or pci_parms[2] != prj_parms:
        print( pci_parms )
        gdaltest.post_reason( 'ExportToPCI result wrong.' )
        return 'fail'

    return 'success'
Exemplo n.º 12
0
def hfa_camera_md():

    ds = gdal.Open( '/vsisparse/data/251_sparse.xml' )

    md = ds.GetMetadata( 'CAMERA_MODEL' )

    check_list = [ ('direction','EMOD_FORWARD'),
                   ('forSrcAffine[0]','0.025004093931786'),
                   ('invDstAffine[0]','1'),
                   ('coeffs[1]','-0.008'),
                   ('elevationType','EPRJ_ELEVATION_TYPE_HEIGHT') ]
    for check_item in check_list:
        try:
            value = md[check_item[0]]
        except:
            gdaltest.post_reason( 'metadata item %d missing' % check_item[0])
            return 'fail'

        if value != check_item[1]:
            gdaltest.post_reason( 'metadata item %s has wrong value: %s' % \
                                  (check_item[0], value) )
            return 'fail'

    # Check that the SRS is reasonable.

    srs_wkt = md['outputProjection']
    exp_wkt = 'PROJCS["UTM Zone 17, Northern Hemisphere",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.978698213898,AUTHORITY["EPSG","7008"]],TOWGS84[-10,158,187,0,0,0,0],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG","4267"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-81],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1],AUTHORITY["EPSG","26717"]]'

    if not gdaltest.equal_srs_from_wkt(srs_wkt,exp_wkt):
        gdaltest.post_reason( 'wrong outputProjection' )
        return 'fail'

    ds = None
    return 'success'
Exemplo n.º 13
0
def test_hfa_camera_md():

    ds = gdal.Open('/vsisparse/data/251_sparse.xml')

    md = ds.GetMetadata('CAMERA_MODEL')

    check_list = [('direction', 'EMOD_FORWARD'),
                  ('forSrcAffine[0]', '0.025004093931786'),
                  ('invDstAffine[0]', '1'), ('coeffs[1]', '-0.008'),
                  ('elevationType', 'EPRJ_ELEVATION_TYPE_HEIGHT')]
    for check_item in check_list:
        try:
            value = md[check_item[0]]
        except IndexError:
            pytest.fail('metadata item %d missing' % check_item[0])

        assert value == check_item[1], (
            'metadata item %s has wrong value: %s' % (check_item[0], value))

    # Check that the SRS is reasonable.

    srs_wkt = md['outputProjection']
    exp_wkt = 'PROJCS["UTM Zone 17, Northern Hemisphere",GEOGCS["NAD27",DATUM["North_American_Datum_1927",SPHEROID["Clarke 1866",6378206.4,294.978698213898,AUTHORITY["EPSG","7008"]],TOWGS84[-10,158,187,0,0,0,0],AUTHORITY["EPSG","6267"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9108"]],AUTHORITY["EPSG","4267"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-81],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["Meter",1],AUTHORITY["EPSG","26717"]]'

    assert gdaltest.equal_srs_from_wkt(srs_wkt,
                                       exp_wkt), 'wrong outputProjection'

    ds = None
Exemplo n.º 14
0
def osr_compd_5():

    srs = osr.SpatialReference()
    srs.SetFromUserInput('EPSG:26911+5703')

    if srs.Validate() != 0:
        gdaltest.post_reason('Does not validate')
        return 'fail'

    exp_wkt = """COMPD_CS["NAD83 / UTM zone 11N + NAVD88 height",
    PROJCS["NAD83 / UTM zone 11N",
        GEOGCS["NAD83",
            DATUM["North_American_Datum_1983",
                SPHEROID["GRS 1980",6378137,298.257222101,
                    AUTHORITY["EPSG","7019"]],
                TOWGS84[0,0,0,0,0,0,0],
                AUTHORITY["EPSG","6269"]],
            PRIMEM["Greenwich",0,
                AUTHORITY["EPSG","8901"]],
            UNIT["degree",0.0174532925199433,
                AUTHORITY["EPSG","9122"]],
            AUTHORITY["EPSG","4269"]],
        PROJECTION["Transverse_Mercator"],
        PARAMETER["latitude_of_origin",0],
        PARAMETER["central_meridian",-117],
        PARAMETER["scale_factor",0.9996],
        PARAMETER["false_easting",500000],
        PARAMETER["false_northing",0],
        UNIT["metre",1,
            AUTHORITY["EPSG","9001"]],
        AXIS["Easting",EAST],
        AXIS["Northing",NORTH],
        AUTHORITY["EPSG","26911"]],
    VERT_CS["NAVD88 height",
        VERT_DATUM["North American Vertical Datum 1988",2005,
            EXTENSION["PROJ4_GRIDS","g2012a_conus.gtx,g2012a_alaska.gtx,g2012a_guam.gtx,g2012a_hawaii.gtx,g2012a_puertorico.gtx,g2012a_samoa.gtx"],
            AUTHORITY["EPSG","5103"]],
        UNIT["metre",1,
            AUTHORITY["EPSG","9001"]],
        AXIS["Up",UP],
        AUTHORITY["EPSG","5703"]]]"""
    wkt = srs.ExportToPrettyWkt()

    if gdaltest.equal_srs_from_wkt(exp_wkt, wkt) == 0:
        return 'fail'
    elif exp_wkt != wkt:
        print('warning they are equivalent, but not completely the same')
        print(wkt)

    if wkt.find('g2012a_conus.gtx') == -1:
        gdaltest.post_reason('Did not get PROJ4_GRIDS EXTENSION node')
        return 'fail'

    exp_proj4 = '+proj=utm +zone=11 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +geoidgrids=g2012a_conus.gtx,g2012a_alaska.gtx,g2012a_guam.gtx,g2012a_hawaii.gtx,g2012a_puertorico.gtx,g2012a_samoa.gtx +vunits=m +no_defs '
    proj4 = srs.ExportToProj4()
    if proj4 != exp_proj4:
        gdaltest.post_reason('Did not get expected proj.4 string, got:' + proj4)
        return 'fail'

    return 'success'
Exemplo n.º 15
0
def osr_compd_5():

    srs = osr.SpatialReference()
    srs.SetFromUserInput( 'EPSG:26911+5703' )

    if srs.Validate() != 0:
        gdaltest.post_reason( 'Does not validate' )
        return 'fail'

    exp_wkt = """COMPD_CS["NAD83 / UTM zone 11N + NAVD88 height",
    PROJCS["NAD83 / UTM zone 11N",
        GEOGCS["NAD83",
            DATUM["North_American_Datum_1983",
                SPHEROID["GRS 1980",6378137,298.257222101,
                    AUTHORITY["EPSG","7019"]],
                TOWGS84[0,0,0,0,0,0,0],
                AUTHORITY["EPSG","6269"]],
            PRIMEM["Greenwich",0,
                AUTHORITY["EPSG","8901"]],
            UNIT["degree",0.0174532925199433,
                AUTHORITY["EPSG","9122"]],
            AUTHORITY["EPSG","4269"]],
        PROJECTION["Transverse_Mercator"],
        PARAMETER["latitude_of_origin",0],
        PARAMETER["central_meridian",-117],
        PARAMETER["scale_factor",0.9996],
        PARAMETER["false_easting",500000],
        PARAMETER["false_northing",0],
        UNIT["metre",1,
            AUTHORITY["EPSG","9001"]],
        AXIS["Easting",EAST],
        AXIS["Northing",NORTH],
        AUTHORITY["EPSG","26911"]],
    VERT_CS["NAVD88 height",
        VERT_DATUM["North American Vertical Datum 1988",2005,
            EXTENSION["PROJ4_GRIDS","g2012a_conus.gtx,g2012a_alaska.gtx,g2012a_guam.gtx,g2012a_hawaii.gtx,g2012a_puertorico.gtx,g2012a_samoa.gtx"],
            AUTHORITY["EPSG","5103"]],
        UNIT["metre",1,
            AUTHORITY["EPSG","9001"]],
        AXIS["Up",UP],
        AUTHORITY["EPSG","5703"]]]"""
    wkt = srs.ExportToPrettyWkt()

    if gdaltest.equal_srs_from_wkt( exp_wkt, wkt ) == 0:
        return 'fail'
    elif exp_wkt != wkt:
        print('warning they are equivalent, but not completely the same')
        print(wkt)

    if wkt.find('g2012a_conus.gtx') == -1:
        gdaltest.post_reason( 'Did not get PROJ4_GRIDS EXTENSION node' )
        return 'fail'

    exp_proj4 = '+proj=utm +zone=11 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +geoidgrids=g2012a_conus.gtx,g2012a_alaska.gtx,g2012a_guam.gtx,g2012a_hawaii.gtx,g2012a_puertorico.gtx,g2012a_samoa.gtx +vunits=m +no_defs '
    proj4 = srs.ExportToProj4()
    if proj4 != exp_proj4:
        gdaltest.post_reason( 'Did not get expected proj.4 string, got:' + proj4 )
        return 'fail'

    return 'success'
Exemplo n.º 16
0
def osr_compd_6():

    if not osr_proj4.have_proj480():
        return 'skip'

    srs = osr.SpatialReference()
    srs.SetFromUserInput(
        '+proj=utm +zone=11 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +geoidgrids=g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx +vunits=us-ft +no_defs '
    )

    if srs.Validate() != 0:
        gdaltest.post_reason('Does not validate')
        return 'fail'

    exp_wkt = """COMPD_CS["UTM Zone 11, Northern Hemisphere + Unnamed Vertical Datum",
    PROJCS["UTM Zone 11, Northern Hemisphere",
        GEOGCS["GRS 1980(IUGG, 1980)",
            DATUM["unknown",
                SPHEROID["GRS80",6378137,298.257222101],
                TOWGS84[0,0,0,0,0,0,0]],
            PRIMEM["Greenwich",0],
            UNIT["degree",0.0174532925199433]],
        PROJECTION["Transverse_Mercator"],
        PARAMETER["latitude_of_origin",0],
        PARAMETER["central_meridian",-117],
        PARAMETER["scale_factor",0.9996],
        PARAMETER["false_easting",500000],
        PARAMETER["false_northing",0],
        UNIT["Meter",1]],
    VERT_CS["Unnamed",
        VERT_DATUM["Unnamed",2005,
            EXTENSION["PROJ4_GRIDS","g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx"]],
        UNIT["Foot_US",0.3048006096012192],
        AXIS["Up",UP]]]"""

    wkt = srs.ExportToPrettyWkt()

    if gdaltest.equal_srs_from_wkt(exp_wkt, wkt) == 0:
        gdaltest.post_reason('fail')
        return 'fail'
    elif exp_wkt != wkt:
        print('warning they are equivalent, but not completely the same')
        print(wkt)

    if wkt.find('g2003conus.gtx') == -1:
        gdaltest.post_reason('Did not get PROJ4_GRIDS EXTENSION node')
        return 'fail'

    exp_proj4 = '+proj=utm +zone=11 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +geoidgrids=g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx +vunits=us-ft +no_defs '
    proj4 = srs.ExportToProj4()
    if proj4 != exp_proj4:
        gdaltest.post_reason('Did not get expected proj.4 string, got:' +
                             proj4)
        return 'fail'

    return 'success'
Exemplo n.º 17
0
def hfa_verify_dataset_projection(dataset_path, exp_wkt):

    ds = gdal.Open( dataset_path )
    srs_wkt = ds.GetProjectionRef()
    if not gdaltest.equal_srs_from_wkt(exp_wkt, srs_wkt):
        gdaltest.post_reason( 'wrong outputProjection' )
        return 'fail'

    ds = None
    return 'success'
Exemplo n.º 18
0
def hfa_verify_dataset_projection(dataset_path, exp_wkt):

    ds = gdal.Open(dataset_path)
    srs_wkt = ds.GetProjectionRef()
    if not gdaltest.equal_srs_from_wkt(exp_wkt, srs_wkt):
        gdaltest.post_reason('wrong outputProjection')
        return 'fail'

    ds = None
    return 'success'
Exemplo n.º 19
0
def osr_compd_7():

    srs_horiz = osr.SpatialReference()
    srs_horiz.ImportFromEPSG( 4326 )

    srs_vert = osr.SpatialReference()
    srs_vert.ImportFromEPSG( 5703 )
    srs_vert.SetTargetLinearUnits( 'VERT_CS', 'foot', 0.304800609601219 )

    srs = osr.SpatialReference()
    srs.SetCompoundCS( 'My Compound SRS', srs_horiz, srs_vert )

    if srs.Validate() != 0:
        gdaltest.post_reason( 'Does not validate' )
        return 'fail'

    exp_wkt = """COMPD_CS["My Compound SRS",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4326"]],
    VERT_CS["NAVD88 height",
        VERT_DATUM["North American Vertical Datum 1988",2005,
            EXTENSION["PROJ4_GRIDS","g2012a_conus.gtx,g2012a_alaska.gtx,g2012a_guam.gtx,g2012a_hawaii.gtx,g2012a_puertorico.gtx,g2012a_samoa.gtx"],
            AUTHORITY["EPSG","5103"]],
        UNIT["foot",0.304800609601219],
        AXIS["Up",UP],
        AUTHORITY["EPSG","5703"]]]"""

    wkt = srs.ExportToPrettyWkt()

    if gdaltest.equal_srs_from_wkt( exp_wkt, wkt ) == 0:
        return 'fail'
    elif exp_wkt != wkt:
        print('warning they are equivalent, but not completely the same')
        print(wkt)

    if srs.GetTargetLinearUnits('VERT_CS') != 0.304800609601219:
        gdaltest.post_reason( 'Didnt get expected linear units' )
        print('%.16g' % srs.GetTargetLinearUnits('VERT_CS'))
        return 'fail'

    if srs.GetTargetLinearUnits(None) != 0.304800609601219:
        gdaltest.post_reason( 'Didnt get expected linear units' )
        print('%.16g' % srs.GetTargetLinearUnits(None))
        return 'fail'

    return 'success'
Exemplo n.º 20
0
def osr_compd_7():

    srs_horiz = osr.SpatialReference()
    srs_horiz.ImportFromEPSG(4326)

    srs_vert = osr.SpatialReference()
    srs_vert.ImportFromEPSG(5703)
    srs_vert.SetTargetLinearUnits('VERT_CS', 'foot', 0.304800609601219)

    srs = osr.SpatialReference()
    srs.SetCompoundCS('My Compound SRS', srs_horiz, srs_vert)

    if srs.Validate() != 0:
        gdaltest.post_reason('Does not validate')
        return 'fail'

    exp_wkt = """COMPD_CS["My Compound SRS",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4326"]],
    VERT_CS["NAVD88 height",
        VERT_DATUM["North American Vertical Datum 1988",2005,
            EXTENSION["PROJ4_GRIDS","g2012a_conus.gtx,g2012a_alaska.gtx,g2012a_guam.gtx,g2012a_hawaii.gtx,g2012a_puertorico.gtx,g2012a_samoa.gtx"],
            AUTHORITY["EPSG","5103"]],
        UNIT["foot",0.304800609601219],
        AXIS["Up",UP],
        AUTHORITY["EPSG","5703"]]]"""

    wkt = srs.ExportToPrettyWkt()

    if gdaltest.equal_srs_from_wkt(exp_wkt, wkt) == 0:
        return 'fail'
    elif exp_wkt != wkt:
        print('warning they are equivalent, but not completely the same')
        print(wkt)

    if srs.GetTargetLinearUnits('VERT_CS') != 0.304800609601219:
        gdaltest.post_reason('Didnt get expected linear units')
        print('%.16g' % srs.GetTargetLinearUnits('VERT_CS'))
        return 'fail'

    if srs.GetTargetLinearUnits(None) != 0.304800609601219:
        gdaltest.post_reason('Didnt get expected linear units')
        print('%.16g' % srs.GetTargetLinearUnits(None))
        return 'fail'

    return 'success'
Exemplo n.º 21
0
def test_osr_ozi_3():

    srs = osr.SpatialReference()
    srs.ImportFromOzi([
        "OziExplorer Map Data File Version 2.2", "Test_Map", "Test_Map.png",
        "1 ,Map Code,", "European 1950 (Mean France),",
        "Map Projection,Latitude/Longitude,,,,,,", "Projection Setup,,,,,,,,,,"
    ])

    expected = 'GEOGCS["European 1950 (Mean France)",DATUM["European 1950 (Mean France)",SPHEROID["International 1924",6378388,297],TOWGS84[-87,-96,-120,0,0,0,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]'

    assert gdaltest.equal_srs_from_wkt(expected, srs.ExportToWkt())
Exemplo n.º 22
0
def osr_compd_6():

    if not osr_proj4.have_proj480():
        return 'skip'

    srs = osr.SpatialReference()
    srs.SetFromUserInput( '+proj=utm +zone=11 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +geoidgrids=g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx +vunits=us-ft +no_defs ' )

    if srs.Validate() != 0:
        gdaltest.post_reason( 'Does not validate' )
        return 'fail'

    exp_wkt = """COMPD_CS["UTM Zone 11, Northern Hemisphere + Unnamed Vertical Datum",
    PROJCS["UTM Zone 11, Northern Hemisphere",
        GEOGCS["GRS 1980(IUGG, 1980)",
            DATUM["unknown",
                SPHEROID["GRS80",6378137,298.257222101],
                TOWGS84[0,0,0,0,0,0,0]],
            PRIMEM["Greenwich",0],
            UNIT["degree",0.0174532925199433]],
        PROJECTION["Transverse_Mercator"],
        PARAMETER["latitude_of_origin",0],
        PARAMETER["central_meridian",-117],
        PARAMETER["scale_factor",0.9996],
        PARAMETER["false_easting",500000],
        PARAMETER["false_northing",0],
        UNIT["Meter",1]],
    VERT_CS["Unnamed",
        VERT_DATUM["Unnamed",2005,
            EXTENSION["PROJ4_GRIDS","g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx"]],
        UNIT["Foot_US",0.3048006096012192],
        AXIS["Up",UP]]]"""

    wkt = srs.ExportToPrettyWkt()

    if gdaltest.equal_srs_from_wkt( exp_wkt, wkt ) == 0:
        gdaltest.post_reason('fail')
        return 'fail'
    elif exp_wkt != wkt:
        print('warning they are equivalent, but not completely the same')
        print(wkt)

    if wkt.find('g2003conus.gtx') == -1:
        gdaltest.post_reason( 'Did not get PROJ4_GRIDS EXTENSION node' )
        return 'fail'

    exp_proj4 = '+proj=utm +zone=11 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +geoidgrids=g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx +vunits=us-ft +no_defs '
    proj4 = srs.ExportToProj4()
    if proj4 != exp_proj4:
        gdaltest.post_reason( 'Did not get expected proj.4 string, got:' + proj4 )
        return 'fail'

    return 'success'
Exemplo n.º 23
0
def test_osr_compd_6():

    srs = osr.SpatialReference()
    srs.SetFromUserInput(
        '+proj=utm +zone=11 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +geoidgrids=g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx +vunits=us-ft +no_defs '
    )

    assert srs.Validate() == 0, 'Does not validate'

    exp_wkt = """COMPD_CS["unknown",
    PROJCS["unknown",
        GEOGCS["unknown",
            DATUM["Unknown_based_on_GRS80_ellipsoid",
                SPHEROID["GRS 1980",6378137,298.257222101,
                    AUTHORITY["EPSG","7019"]],
                TOWGS84[0,0,0,0,0,0,0]],
            PRIMEM["Greenwich",0,
                AUTHORITY["EPSG","8901"]],
            UNIT["degree",0.0174532925199433,
                AUTHORITY["EPSG","9122"]]],
        PROJECTION["Transverse_Mercator"],
        PARAMETER["latitude_of_origin",0],
        PARAMETER["central_meridian",-117],
        PARAMETER["scale_factor",0.9996],
        PARAMETER["false_easting",500000],
        PARAMETER["false_northing",0],
        UNIT["metre",1,
            AUTHORITY["EPSG","9001"]],
        AXIS["Easting",EAST],
        AXIS["Northing",NORTH]],
    VERT_CS["unknown",
        VERT_DATUM["unknown",2005,
            EXTENSION["PROJ4_GRIDS","g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx"]],
        UNIT["US survey foot",0.304800609601219,
            AUTHORITY["EPSG","9003"]],
        AXIS["Gravity-related height",UP]]]"""

    wkt = srs.ExportToPrettyWkt()

    if gdaltest.equal_srs_from_wkt(exp_wkt, wkt) == 0:
        pytest.fail()
    elif exp_wkt != wkt:
        print('warning they are equivalent, but not completely the same')
        print(wkt)

    assert wkt.find(
        'g2003conus.gtx') != -1, 'Did not get PROJ4_GRIDS EXTENSION node'

    exp_proj4 = '+proj=utm +zone=11 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +geoidgrids=g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx +vunits=us-ft +no_defs'
    proj4 = srs.ExportToProj4()
    assert proj4 == exp_proj4, ('Did not get expected proj.4 string, got:' +
                                proj4)
Exemplo n.º 24
0
def osr_ozi_1():

    srs = osr.SpatialReference()
    srs.ImportFromOzi("WGS 84,WGS 84,   0.0000,   0.0000,WGS 84",
                      "Map Projection,Lambert Conformal Conic,PolyCal,No,AutoCalOnly,No,BSBUseWPX,No",
                      "Projection Setup,     4.000000000,    10.000000000,,,,    40.000000000,    56.000000000,,,")

    expected = 'PROJCS["unnamed",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4326"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",40],PARAMETER["standard_parallel_2",56],PARAMETER["latitude_of_origin",4],PARAMETER["central_meridian",10],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]]'

    if not gdaltest.equal_srs_from_wkt( expected, srs.ExportToWkt() ):
        return 'fail'

    return 'success'
Exemplo n.º 25
0
def osr_ozi_3():

    srs = osr.SpatialReference()
    srs.ImportFromOzi("European 1950 (Mean France),",
                      "Map Projection,Latitude/Longitude,,,,,,",
                      "Projection Setup,,,,,,,,,,")

    expected = 'GEOGCS["European 1950 (Mean France)",DATUM["European 1950 (Mean France)",SPHEROID["International 1924",6378388,297],TOWGS84[-87,-96,-120,0,0,0,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]'

    if not gdaltest.equal_srs_from_wkt( expected, srs.ExportToWkt() ):
        return 'fail'

    return 'success'
Exemplo n.º 26
0
def test_osr_pci_6():

    prj_parms = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

    srs = osr.SpatialReference()
    srs.ImportFromPCI('LONG/LAT    D030', 'DEGREE', prj_parms)

    expected = 'GEOGCS["AGD84",DATUM["Australian_Geodetic_Datum_1984",SPHEROID["Australian National Spheroid",6378160,298.25,AUTHORITY["EPSG","7003"]],TOWGS84[-117.763,-51.51,139.061,0.292,0.443,0.277,-0.191],AUTHORITY["EPSG","6203"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4203"]]'

    assert gdaltest.equal_srs_from_wkt(expected, srs.ExportToWkt())

    pci_parms = srs.ExportToPCI()
    assert pci_parms[0] == 'LONG/LAT    D030' and pci_parms[1] == 'DEGREE' and pci_parms[2] == prj_parms, \
        'ExportToPCI result wrong.'
Exemplo n.º 27
0
def test_osr_pci_5():

    prj_parms = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

    srs = osr.SpatialReference()
    srs.ImportFromPCI('LONG/LAT    E224', 'DEGREE', prj_parms)

    expected = 'GEOGCS["Unknown - PCI E224",DATUM["Unknown - PCI E224",SPHEROID["Xian 1980",6378140,298.2569978029123]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]'

    assert gdaltest.equal_srs_from_wkt(expected, srs.ExportToWkt())

    pci_parms = srs.ExportToPCI()
    assert pci_parms[0] == 'LONG/LAT    E224' and pci_parms[1] == 'DEGREE' and pci_parms[2] == prj_parms, \
        'ExportToPCI result wrong.'
Exemplo n.º 28
0
def test_osr_pci_4():

    prj_parms = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

    srs = osr.SpatialReference()
    srs.ImportFromPCI('LONG/LAT    D506', 'DEGREE', prj_parms)

    expected = 'GEOGCS["Rijksdriehoeks Datum",DATUM["Rijksdriehoeks Datum",SPHEROID["Bessel 1841",6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],TOWGS84[565.04,49.91,465.84,0.4094,-0.3597,1.8685,4.077200000063286]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]'

    assert gdaltest.equal_srs_from_wkt(expected, srs.ExportToWkt())

    pci_parms = srs.ExportToPCI()
    assert pci_parms[0] == 'LONG/LAT    D506' and pci_parms[1] == 'DEGREE' and pci_parms[2] == prj_parms, \
        'ExportToPCI result wrong.'
Exemplo n.º 29
0
def test_osr_ozi_3():

    srs = osr.SpatialReference()
    srs.ImportFromOzi(["OziExplorer Map Data File Version 2.2",
                       "Test_Map",
                       "Test_Map.png",
                       "1 ,Map Code,",
                       "European 1950 (Mean France),",
                       "Map Projection,Latitude/Longitude,,,,,,",
                       "Projection Setup,,,,,,,,,,"])

    expected = 'GEOGCS["European 1950 (Mean France)",DATUM["European 1950 (Mean France)",SPHEROID["International 1924",6378388,297],TOWGS84[-87,-96,-120,0,0,0,0]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]'

    assert gdaltest.equal_srs_from_wkt(expected, srs.ExportToWkt())
Exemplo n.º 30
0
def test_osr_pci_5():

    prj_parms = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

    srs = osr.SpatialReference()
    srs.ImportFromPCI('LONG/LAT    E224', 'DEGREE', prj_parms)

    expected = 'GEOGCS["Unknown - PCI E224",DATUM["Unknown - PCI E224",SPHEROID["Xian 1980",6378140,298.2569978029123]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]'

    assert gdaltest.equal_srs_from_wkt(expected, srs.ExportToWkt())

    pci_parms = srs.ExportToPCI()
    assert pci_parms[0] == 'LONG/LAT    E224' and pci_parms[1] == 'DEGREE' and pci_parms[2] == prj_parms, \
        'ExportToPCI result wrong.'
Exemplo n.º 31
0
def osr_compd_3():

    srs = osr.SpatialReference()
    srs.ImportFromEPSG(7401)

    if srs.Validate() != 0:
        gdaltest.post_reason('Does not validate')
        return 'fail'

    exp_wkt = """COMPD_CS["NTF (Paris) / France II + NGF Lallemand",
    PROJCS["NTF (Paris) / France II (deprecated)",
        GEOGCS["NTF (Paris)",
            DATUM["Nouvelle_Triangulation_Francaise_Paris",
                SPHEROID["Clarke 1880 (IGN)",6378249.2,293.4660212936265,
                    AUTHORITY["EPSG","7011"]],
                TOWGS84[-168,-60,320,0,0,0,0],
                AUTHORITY["EPSG","6807"]],
            PRIMEM["Paris",2.33722917,
                AUTHORITY["EPSG","8903"]],
            UNIT["grad",0.01570796326794897,
                AUTHORITY["EPSG","9105"]],
            AUTHORITY["EPSG","4807"]],
        PROJECTION["Lambert_Conformal_Conic_1SP"],
        PARAMETER["latitude_of_origin",52],
        PARAMETER["central_meridian",0],
        PARAMETER["scale_factor",0.99987742],
        PARAMETER["false_easting",600000],
        PARAMETER["false_northing",2200000],
        UNIT["metre",1,
            AUTHORITY["EPSG","9001"]],
        AXIS["X",EAST],
        AXIS["Y",NORTH],
        AUTHORITY["EPSG","27582"]],
    VERT_CS["NGF Lallemand height",
        VERT_DATUM["Nivellement General de la France - Lallemand",2005,
            AUTHORITY["EPSG","5118"]],
        UNIT["metre",1,
            AUTHORITY["EPSG","9001"]],
        AXIS["Up",UP],
        AUTHORITY["EPSG","5719"]],
    AUTHORITY["EPSG","7401"]]"""
    wkt = srs.ExportToPrettyWkt()
    if gdaltest.equal_srs_from_wkt(exp_wkt, wkt) == 0:
        gdaltest.post_reason('did not get expected compound cs for EPSG:7401')
        return 'fail'
    # elif exp_wkt != wkt:
    #    print('warning they are equivalent, but not completely the same')
    #    print(wkt)

    return 'success'
Exemplo n.º 32
0
def test_osr_pci_4():

    prj_parms = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

    srs = osr.SpatialReference()
    srs.ImportFromPCI('LONG/LAT    D506', 'DEGREE', prj_parms)

    expected = 'GEOGCS["Rijksdriehoeks Datum",DATUM["Rijksdriehoeks Datum",SPHEROID["Bessel 1841",6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],TOWGS84[565.04,49.91,465.84,0.4094,-0.3597,1.8685,4.077200000063286]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]'

    assert gdaltest.equal_srs_from_wkt(expected, srs.ExportToWkt())

    pci_parms = srs.ExportToPCI()
    assert pci_parms[0] == 'LONG/LAT    D506' and pci_parms[1] == 'DEGREE' and pci_parms[2] == prj_parms, \
        'ExportToPCI result wrong.'
Exemplo n.º 33
0
def osr_ozi_2():

    srs = osr.SpatialReference()
    srs.ImportFromOzi("Tokyo,",
                      "Map Projection,Latitude/Longitude,,,,,,",
                      "Projection Setup,,,,,,,,,,")

    srs_ref = osr.SpatialReference()
    srs_ref.ImportFromEPSG(4301)

    if not gdaltest.equal_srs_from_wkt( srs_ref.ExportToWkt(), srs.ExportToWkt() ):
        return 'fail'

    return 'success'
Exemplo n.º 34
0
def osr_compd_3():

    srs = osr.SpatialReference()
    srs.ImportFromEPSG( 7401 )

    if srs.Validate() != 0:
        gdaltest.post_reason( 'Does not validate' )
        return 'fail'

    exp_wkt = """COMPD_CS["NTF (Paris) / France II + NGF Lallemand",
    PROJCS["NTF (Paris) / France II (deprecated)",
        GEOGCS["NTF (Paris)",
            DATUM["Nouvelle_Triangulation_Francaise_Paris",
                SPHEROID["Clarke 1880 (IGN)",6378249.2,293.4660212936265,
                    AUTHORITY["EPSG","7011"]],
                TOWGS84[-168,-60,320,0,0,0,0],
                AUTHORITY["EPSG","6807"]],
            PRIMEM["Paris",2.33722917,
                AUTHORITY["EPSG","8903"]],
            UNIT["grad",0.01570796326794897,
                AUTHORITY["EPSG","9105"]],
            AUTHORITY["EPSG","4807"]],
        PROJECTION["Lambert_Conformal_Conic_1SP"],
        PARAMETER["latitude_of_origin",52],
        PARAMETER["central_meridian",0],
        PARAMETER["scale_factor",0.99987742],
        PARAMETER["false_easting",600000],
        PARAMETER["false_northing",2200000],
        UNIT["metre",1,
            AUTHORITY["EPSG","9001"]],
        AXIS["X",EAST],
        AXIS["Y",NORTH],
        AUTHORITY["EPSG","27582"]],
    VERT_CS["NGF Lallemand height",
        VERT_DATUM["Nivellement General de la France - Lallemand",2005,
            AUTHORITY["EPSG","5118"]],
        UNIT["metre",1,
            AUTHORITY["EPSG","9001"]],
        AXIS["Up",UP],
        AUTHORITY["EPSG","5719"]],
    AUTHORITY["EPSG","7401"]]"""
    wkt = srs.ExportToPrettyWkt()
    if gdaltest.equal_srs_from_wkt( exp_wkt, wkt ) == 0:
        gdaltest.post_reason( 'did not get expected compound cs for EPSG:7401')
        return 'fail'
    # elif exp_wkt != wkt:
    #    print('warning they are equivalent, but not completely the same')
    #    print(wkt)

    return 'success'
Exemplo n.º 35
0
def test_osr_ozi_2():

    srs = osr.SpatialReference()
    srs.ImportFromOzi([
        "OziExplorer Map Data File Version 2.2", "Test_Map", "Test_Map.png",
        "1 ,Map Code,", "Tokyo,", "Map Projection,Latitude/Longitude,,,,,,",
        "Projection Setup,,,,,,,,,,"
    ])

    srs_ref = osr.SpatialReference()
    srs_ref.ImportFromEPSG(4301)

    assert gdaltest.equal_srs_from_wkt(srs_ref.ExportToWkt(),
                                       srs.ExportToWkt())
Exemplo n.º 36
0
def test_osr_compd_5():

    srs = osr.SpatialReference()
    srs.SetFromUserInput('EPSG:26911+5703')

    assert srs.Validate() == 0, 'Does not validate'

    exp_wkt = """COMPD_CS["NAD83 / UTM zone 11N + NAVD88 height",
    PROJCS["NAD83 / UTM zone 11N",
        GEOGCS["NAD83",
            DATUM["North_American_Datum_1983",
                SPHEROID["GRS 1980",6378137,298.257222101,
                    AUTHORITY["EPSG","7019"]],
                TOWGS84[0,0,0,0,0,0,0],
                AUTHORITY["EPSG","6269"]],
            PRIMEM["Greenwich",0,
                AUTHORITY["EPSG","8901"]],
            UNIT["degree",0.0174532925199433,
                AUTHORITY["EPSG","9122"]],
            AUTHORITY["EPSG","4269"]],
        PROJECTION["Transverse_Mercator"],
        PARAMETER["latitude_of_origin",0],
        PARAMETER["central_meridian",-117],
        PARAMETER["scale_factor",0.9996],
        PARAMETER["false_easting",500000],
        PARAMETER["false_northing",0],
        UNIT["metre",1,
            AUTHORITY["EPSG","9001"]],
        AXIS["Easting",EAST],
        AXIS["Northing",NORTH],
        AUTHORITY["EPSG","26911"]],
    VERT_CS["NAVD88 height",
        VERT_DATUM["North American Vertical Datum 1988",2005,
            AUTHORITY["EPSG","5103"]],
        UNIT["metre",1,
            AUTHORITY["EPSG","9001"]],
        AXIS["Gravity-related height",UP],
        AUTHORITY["EPSG","5703"]]]"""
    wkt = srs.ExportToPrettyWkt()

    if gdaltest.equal_srs_from_wkt(exp_wkt, wkt) == 0:
        pytest.fail()
    elif exp_wkt != wkt:
        print('warning they are equivalent, but not completely the same')
        print(wkt)

    exp_proj4 = '+proj=utm +zone=11 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +vunits=m +no_defs'
    proj4 = srs.ExportToProj4()
    assert proj4 == exp_proj4, ('Did not get expected proj.4 string, got:' +
                                proj4)
Exemplo n.º 37
0
def test_osr_pci_6():

    prj_parms = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

    srs = osr.SpatialReference()
    srs.ImportFromPCI('LONG/LAT    D030', 'DEGREE', prj_parms)

    expected = 'GEOGCS["AGD84",DATUM["Australian_Geodetic_Datum_1984",SPHEROID["Australian National Spheroid",6378160,298.25,AUTHORITY["EPSG","7003"]],TOWGS84[-134,-48,149,0,0,0,0],AUTHORITY["EPSG","6203"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4203"]]'

    assert gdaltest.equal_srs_from_wkt(expected, srs.ExportToWkt())

    pci_parms = srs.ExportToPCI()
    assert pci_parms[0] == 'LONG/LAT    D030' and pci_parms[1] == 'DEGREE' and pci_parms[2] == prj_parms, \
        'ExportToPCI result wrong.'
Exemplo n.º 38
0
def test_hfa_mapinformation_units():

    # NOTE: we depend on being able to open .aux files as a weak sort of
    # dataset.

    gdal.PushErrorHandler('CPLQuietErrorHandler')
    ds = gdal.Open('data/fg118-91.aux')
    gdal.PopErrorHandler()

    wkt = ds.GetProjectionRef()
    expected_wkt = """PROJCS["NAD_1983_StatePlane_Virginia_North_FIPS_4501_Feet",GEOGCS["GCS_North_American_1983",DATUM["North_American_Datum_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199432955],AUTHORITY["EPSG","4269"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["False_Easting",11482916.66666666],PARAMETER["False_Northing",6561666.666666666],PARAMETER["Central_Meridian",-78.5],PARAMETER["Standard_Parallel_1",38.03333333333333],PARAMETER["Standard_Parallel_2",39.2],PARAMETER["Latitude_Of_Origin",37.66666666666666],UNIT["Foot_US",0.304800609601219241]]"""

    if gdaltest.equal_srs_from_wkt(expected_wkt, wkt):
        return
    pytest.fail()
Exemplo n.º 39
0
def test_hfa_mapinformation_units():

    # NOTE: we depend on being able to open .aux files as a weak sort of
    # dataset.

    gdal.PushErrorHandler('CPLQuietErrorHandler')
    ds = gdal.Open('data/fg118-91.aux')
    gdal.PopErrorHandler()

    wkt = ds.GetProjectionRef()
    expected_wkt = """PROJCS["NAD_1983_StatePlane_Virginia_North_FIPS_4501_Feet",GEOGCS["GCS_North_American_1983",DATUM["North_American_Datum_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.0174532925199432955],AUTHORITY["EPSG","4269"]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["False_Easting",11482916.66666666],PARAMETER["False_Northing",6561666.666666666],PARAMETER["Central_Meridian",-78.5],PARAMETER["Standard_Parallel_1",38.03333333333333],PARAMETER["Standard_Parallel_2",39.2],PARAMETER["Latitude_Of_Origin",37.66666666666666],UNIT["Foot_US",0.304800609601219241]]"""

    if gdaltest.equal_srs_from_wkt(expected_wkt, wkt):
        return
    pytest.fail()
Exemplo n.º 40
0
def test_osr_ozi_2():

    srs = osr.SpatialReference()
    srs.ImportFromOzi(["OziExplorer Map Data File Version 2.2",
                       "Test_Map",
                       "Test_Map.png",
                       "1 ,Map Code,",
                       "Tokyo,",
                       "Map Projection,Latitude/Longitude,,,,,,",
                       "Projection Setup,,,,,,,,,,"])

    srs_ref = osr.SpatialReference()
    srs_ref.ImportFromEPSG(4301)

    assert gdaltest.equal_srs_from_wkt(srs_ref.ExportToWkt(), srs.ExportToWkt())
Exemplo n.º 41
0
def test_osr_pci_1():

    prj_parms = (0.0, 0.0, 45.0, 54.5, 47.0, 62.0, 0.0, 0.0, 0.0, 0.0, 0.0,
                 0.0, 0.0, 0.0, 0.0, 0.0, 0.0)
    srs = osr.SpatialReference()
    srs.ImportFromPCI('EC          E015', 'METRE', prj_parms)

    assert srs.GetProjParm(osr.SRS_PP_STANDARD_PARALLEL_1) == pytest.approx(47.0, abs=0.0000005) and srs.GetProjParm(osr.SRS_PP_STANDARD_PARALLEL_2) == pytest.approx(62.0, abs=0.0000005) and srs.GetProjParm(osr.SRS_PP_LATITUDE_OF_CENTER) == pytest.approx(54.5, abs=0.0000005) and srs.GetProjParm(osr.SRS_PP_LONGITUDE_OF_CENTER) == pytest.approx(45.0, abs=0.0000005) and srs.GetProjParm(osr.SRS_PP_FALSE_EASTING) == pytest.approx(0.0, abs=0.0000005) and srs.GetProjParm(osr.SRS_PP_FALSE_NORTHING) == pytest.approx(0.0, abs=0.0000005), \
        'Can not import Equidistant Conic projection.'

    expected = 'PROJCS["unnamed",GEOGCS["Unknown - PCI E015",DATUM["Unknown - PCI E015",SPHEROID["Krassowsky 1940",6378245,298.3,AUTHORITY["EPSG","7024"]]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]],PROJECTION["Equidistant_Conic"],PARAMETER["standard_parallel_1",47],PARAMETER["standard_parallel_2",62],PARAMETER["latitude_of_center",54.5],PARAMETER["longitude_of_center",45],PARAMETER["false_easting",0],PARAMETER["false_northing",0],UNIT["Meter",1]]'

    assert gdaltest.equal_srs_from_wkt(expected, srs.ExportToWkt())

    pci_parms = srs.ExportToPCI()
    assert pci_parms[0] == 'EC          E015' and pci_parms[1] == 'METRE' and pci_parms[2] == prj_parms, \
        'ExportToPCI result wrong.'
Exemplo n.º 42
0
def test_osr_proj4_10():

    srs = osr.SpatialReference()
    srs.ImportFromProj4('+proj=geocent +ellps=WGS84 +towgs84=0,0,0 ')

    wkt_expected = 'GEOCCS["unknown",DATUM["Unknown_based_on_WGS84_ellipsoid",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Geocentric X",OTHER],AXIS["Geocentric Y",OTHER],AXIS["Geocentric Z",NORTH]]'

    assert gdaltest.equal_srs_from_wkt(wkt_expected, srs.ExportToWkt()), \
        'did not get expected wkt.'

    p4 = srs.ExportToProj4()
    srs2 = osr.SpatialReference()
    srs2.ImportFromProj4(p4)

    if not srs.IsSame(srs2):
        print(srs.ExportToPrettyWkt())
        print(srs2.ExportToPrettyWkt())
        pytest.fail('round trip via PROJ.4 damaged srs?')
Exemplo n.º 43
0
def test_osr_proj4_10():

    srs = osr.SpatialReference()
    srs.ImportFromProj4('+proj=geocent +ellps=WGS84 +towgs84=0,0,0 ')

    wkt_expected = 'GEOCCS["unknown",DATUM["Unknown_based_on_WGS84_ellipsoid",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],TOWGS84[0,0,0,0,0,0,0]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AXIS["Geocentric X",OTHER],AXIS["Geocentric Y",OTHER],AXIS["Geocentric Z",NORTH]]'

    assert gdaltest.equal_srs_from_wkt(wkt_expected, srs.ExportToWkt()), \
        'did not get expected wkt.'

    p4 = srs.ExportToProj4()
    srs2 = osr.SpatialReference()
    srs2.ImportFromProj4(p4)

    if not srs.IsSame(srs2):
        print(srs.ExportToPrettyWkt())
        print(srs2.ExportToPrettyWkt())
        pytest.fail('round trip via PROJ.4 damaged srs?')
Exemplo n.º 44
0
def test_osr_proj4_10():

    srs = osr.SpatialReference()
    srs.ImportFromProj4('+proj=geocent +ellps=WGS84 +towgs84=0,0,0 ')

    wkt_expected = 'GEOCCS["Geocentric",DATUM["unknown",SPHEROID["WGS84",6378137,298.257223563],TOWGS84[0,0,0,0,0,0,0]],PRIMEM["Greenwich",0]]'

    assert gdaltest.equal_srs_from_wkt(wkt_expected, srs.ExportToWkt()), \
        'did not get expected wkt.'

    p4 = srs.ExportToProj4()
    srs2 = osr.SpatialReference()
    srs2.ImportFromProj4(p4)

    if not srs.IsSame(srs2):
        print(srs.ExportToPrettyWkt())
        print(srs2.ExportToPrettyWkt())
        pytest.fail('round trip via PROJ.4 damaged srs?')
Exemplo n.º 45
0
def test_osr_proj4_10():

    srs = osr.SpatialReference()
    srs.ImportFromProj4('+proj=geocent +ellps=WGS84 +towgs84=0,0,0 ')

    wkt_expected = 'GEOCCS["Geocentric",DATUM["unknown",SPHEROID["WGS84",6378137,298.257223563],TOWGS84[0,0,0,0,0,0,0]],PRIMEM["Greenwich",0]]'

    assert gdaltest.equal_srs_from_wkt(wkt_expected, srs.ExportToWkt()), \
        'did not get expected wkt.'

    p4 = srs.ExportToProj4()
    srs2 = osr.SpatialReference()
    srs2.ImportFromProj4(p4)

    if not srs.IsSame(srs2):
        print(srs.ExportToPrettyWkt())
        print(srs2.ExportToPrettyWkt())
        pytest.fail('round trip via PROJ.4 damaged srs?')
Exemplo n.º 46
0
def test_osr_compd_7():

    srs_horiz = osr.SpatialReference()
    srs_horiz.ImportFromEPSG(4326)

    srs_vert = osr.SpatialReference()
    srs_vert.ImportFromEPSG(5703)
    srs_vert.SetTargetLinearUnits('VERT_CS', 'foot', 0.304800609601219)

    srs = osr.SpatialReference()
    srs.SetCompoundCS('My Compound SRS', srs_horiz, srs_vert)

    assert srs.Validate() == 0, 'Does not validate'

    exp_wkt = """COMPD_CS["My Compound SRS",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4326"]],
    VERT_CS["NAVD88 height",
        VERT_DATUM["North American Vertical Datum 1988",2005,
            AUTHORITY["EPSG","5103"]],
        UNIT["foot",0.304800609601219],
        AXIS["Gravity-related height",UP]]]"""

    wkt = srs.ExportToPrettyWkt()

    if gdaltest.equal_srs_from_wkt(exp_wkt, wkt) == 0:
        pytest.fail()
    elif exp_wkt != wkt:
        print('warning they are equivalent, but not completely the same')
        print(wkt)

    assert srs.GetTargetLinearUnits('VERT_CS') == pytest.approx(
        0.304800609601219, 1e-15)

    assert srs.GetTargetLinearUnits(None) == pytest.approx(
        0.304800609601219, 1e-15)
Exemplo n.º 47
0
def test_osr_compd_3():

    srs = osr.SpatialReference()
    srs.ImportFromEPSG(7401)

    assert srs.Validate() == 0, 'Does not validate'

    exp_wkt = """COMPD_CS["NTF (Paris) / France II + NGF Lallemand",
    PROJCS["NTF (Paris) / France II (deprecated)",
        GEOGCS["NTF (Paris)",
            DATUM["Nouvelle_Triangulation_Francaise_Paris",
                SPHEROID["Clarke 1880 (IGN)",6378249.2,293.4660212936265,
                    AUTHORITY["EPSG","7011"]],
                AUTHORITY["EPSG","6807"]],
            PRIMEM["Paris",2.33722917,
                AUTHORITY["EPSG","8903"]],
            UNIT["grad",0.01570796326794897,
                AUTHORITY["EPSG","9105"]],
            AUTHORITY["EPSG","4807"]],
        PROJECTION["Lambert_Conformal_Conic_1SP"],
        PARAMETER["latitude_of_origin",52],
        PARAMETER["central_meridian",0],
        PARAMETER["scale_factor",0.99987742],
        PARAMETER["false_easting",600000],
        PARAMETER["false_northing",2200000],
        UNIT["metre",1,
            AUTHORITY["EPSG","9001"]],
        AXIS["X",EAST],
        AXIS["Y",NORTH],
        AUTHORITY["EPSG","27582"]],
    VERT_CS["NGF Lallemand height",
        VERT_DATUM["Nivellement General de la France - Lallemand",2005,
            AUTHORITY["EPSG","5118"]],
        UNIT["metre",1,
            AUTHORITY["EPSG","9001"]],
        AXIS["Gravity-related height",UP],
        AUTHORITY["EPSG","5719"]],
    AUTHORITY["EPSG","7401"]]"""
    wkt = srs.ExportToPrettyWkt()
    assert gdaltest.equal_srs_from_wkt(exp_wkt, wkt) != 0, \
        'did not get expected compound cs for EPSG:7401'
Exemplo n.º 48
0
def osr_pci_5():

    prj_parms = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

    srs = osr.SpatialReference()
    srs.ImportFromPCI('LONG/LAT    E224', 'DEGREE', prj_parms)

    expected = 'GEOGCS["Unknown - PCI E224",DATUM["Unknown - PCI E224",SPHEROID["Xian 1980",6378140,298.2569978029123]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]'

    if not gdaltest.equal_srs_from_wkt(expected, srs.ExportToWkt()):
        return 'fail'

    pci_parms = srs.ExportToPCI()
    if pci_parms[0] != 'LONG/LAT    E224' \
       or pci_parms[1] != 'DEGREE' \
       or pci_parms[2] != prj_parms:
        print(pci_parms)
        gdaltest.post_reason('ExportToPCI result wrong.')
        return 'fail'

    return 'success'
Exemplo n.º 49
0
def osr_pci_6():

    prj_parms = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

    srs = osr.SpatialReference()
    srs.ImportFromPCI('LONG/LAT    D030', 'DEGREE', prj_parms)

    expected = 'GEOGCS["AGD84",DATUM["Australian_Geodetic_Datum_1984",SPHEROID["Australian National Spheroid",6378160,298.25,AUTHORITY["EPSG","7003"]],TOWGS84[-134,-48,149,0,0,0,0],AUTHORITY["EPSG","6203"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4203"]]'

    if not gdaltest.equal_srs_from_wkt(expected, srs.ExportToWkt()):
        return 'fail'

    pci_parms = srs.ExportToPCI()
    if pci_parms[0] != 'LONG/LAT    D030' \
       or pci_parms[1] != 'DEGREE' \
       or pci_parms[2] != prj_parms:
        print(pci_parms)
        gdaltest.post_reason('ExportToPCI result wrong.')
        return 'fail'

    return 'success'
Exemplo n.º 50
0
def osr_pci_6():

    prj_parms = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

    srs = osr.SpatialReference()
    srs.ImportFromPCI('LONG/LAT    D030', 'DEGREE', prj_parms )

    expected = 'GEOGCS["AGD84",DATUM["Australian_Geodetic_Datum_1984",SPHEROID["Australian National Spheroid",6378160,298.25,AUTHORITY["EPSG","7003"]],TOWGS84[-134,-48,149,0,0,0,0],AUTHORITY["EPSG","6203"]],PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],UNIT["degree",0.0174532925199433,AUTHORITY["EPSG","9122"]],AUTHORITY["EPSG","4203"]]'

    if not gdaltest.equal_srs_from_wkt( expected, srs.ExportToWkt() ):
        return 'fail'

    pci_parms = srs.ExportToPCI()
    if pci_parms[0] != 'LONG/LAT    D030' \
       or pci_parms[1] != 'DEGREE' \
       or pci_parms[2] != prj_parms:
        print( pci_parms )
        gdaltest.post_reason( 'ExportToPCI result wrong.' )
        return 'fail'

    return 'success'
Exemplo n.º 51
0
def osr_pci_5():

    prj_parms = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

    srs = osr.SpatialReference()
    srs.ImportFromPCI('LONG/LAT    E224', 'DEGREE', prj_parms )

    expected = 'GEOGCS["Unknown - PCI E224",DATUM["Unknown - PCI E224",SPHEROID["Xian 1980",6378140,298.2569978029123]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]'

    if not gdaltest.equal_srs_from_wkt( expected, srs.ExportToWkt() ):
        return 'fail'

    pci_parms = srs.ExportToPCI()
    if pci_parms[0] != 'LONG/LAT    E224' \
       or pci_parms[1] != 'DEGREE' \
       or pci_parms[2] != prj_parms:
        print( pci_parms )
        gdaltest.post_reason( 'ExportToPCI result wrong.' )
        return 'fail'

    return 'success'
Exemplo n.º 52
0
def osr_pci_4():

    prj_parms = (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)

    srs = osr.SpatialReference()
    srs.ImportFromPCI('LONG/LAT    D506', 'DEGREE', prj_parms )

    expected = 'GEOGCS["Rijksdriehoeks Datum",DATUM["Rijksdriehoeks Datum",SPHEROID["Bessel 1841",6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],TOWGS84[565.04,49.91,465.84,0.4094,-0.3597,1.8685,4.077200000063286]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433]]'

    if not gdaltest.equal_srs_from_wkt( expected, srs.ExportToWkt() ):
        return 'fail'

    pci_parms = srs.ExportToPCI()
    if pci_parms[0] != 'LONG/LAT    D506' \
       or pci_parms[1] != 'DEGREE' \
       or pci_parms[2] != prj_parms:
        print( pci_parms )
        gdaltest.post_reason( 'ExportToPCI result wrong.' )
        return 'fail'

    return 'success'
Exemplo n.º 53
0
def test_jpipkak_2():

    pytest.skip()

    # pylint: disable=unreachable
    if gdaltest.jpipkak_drv is None:
        pytest.skip()

    ds = gdal.Open('jpip://216.150.195.220/JP2Server/qb_boulder_pan_byte')
    assert ds is not None, 'failed to open jpip stream.'

    wkt = ds.GetProjectionRef()
    exp_wkt = 'PROJCS["WGS 84 / UTM zone 13N",GEOGCS["WGS 84",DATUM["WGS_1984",SPHEROID["WGS 84",6378137,298.257223563,AUTHORITY["EPSG","7030"]],AUTHORITY["EPSG","6326"]],PRIMEM["Greenwich",0],UNIT["degree",0.0174532925199433],AUTHORITY["EPSG","4326"]],PROJECTION["Transverse_Mercator"],PARAMETER["latitude_of_origin",0],PARAMETER["central_meridian",-105],PARAMETER["scale_factor",0.9996],PARAMETER["false_easting",500000],PARAMETER["false_northing",0],UNIT["metre",1,AUTHORITY["EPSG","9001"]],AUTHORITY["EPSG","32613"]]'

    assert gdaltest.equal_srs_from_wkt(exp_wkt, wkt)

    target = ds.GetRasterBand(1).GetOverview(3)

    stats = target.GetStatistics(0, 1)

    assert abs(stats[2] - 43.429) <= 1.0 and abs(stats[3] - 18.526) <= 1.0, \
        'did not get expected mean/stddev'
Exemplo n.º 54
0
def osr_proj4_10():

    srs = osr.SpatialReference()
    srs.ImportFromProj4("+proj=geocent +ellps=WGS84 +towgs84=0,0,0 ")

    wkt_expected = 'GEOCCS["Geocentric",DATUM["unknown",SPHEROID["WGS84",6378137,298.257223563],TOWGS84[0,0,0,0,0,0,0]],PRIMEM["Greenwich",0]]'

    if not gdaltest.equal_srs_from_wkt(wkt_expected, srs.ExportToWkt()):
        gdaltest.post_reason("did not get expected wkt.")
        return "fail"

    p4 = srs.ExportToProj4()
    srs2 = osr.SpatialReference()
    srs2.ImportFromProj4(p4)

    if not srs.IsSame(srs2):
        gdaltest.post_reason("round trip via PROJ.4 damaged srs?")
        print(srs.ExportToPrettyWkt())
        print(srs2.ExportToPrettyWkt())
        return "fail"

    return "success"
Exemplo n.º 55
0
def osr_compd_4():

    srs = osr.SpatialReference()
    srs.ImportFromEPSG( 7400 )

    if srs.Validate() != 0:
        gdaltest.post_reason( 'Does not validate' )
        return 'fail'

    exp_wkt = """COMPD_CS["NTF (Paris) + NGF IGN69 height",
    GEOGCS["NTF (Paris)",
        DATUM["Nouvelle_Triangulation_Francaise_Paris",
            SPHEROID["Clarke 1880 (IGN)",6378249.2,293.4660212936265,
                AUTHORITY["EPSG","7011"]],
            TOWGS84[-168,-60,320,0,0,0,0],
            AUTHORITY["EPSG","6807"]],
        PRIMEM["Paris",2.33722917,
            AUTHORITY["EPSG","8903"]],
        UNIT["grad",0.01570796326794897,
            AUTHORITY["EPSG","9105"]],
        AUTHORITY["EPSG","4807"]],
    VERT_CS["NGF-IGN69 height",
        VERT_DATUM["Nivellement General de la France - IGN69",2005,
            AUTHORITY["EPSG","5119"]],
        UNIT["metre",1,
            AUTHORITY["EPSG","9001"]],
        AXIS["Up",UP],
        AUTHORITY["EPSG","5720"]],
    AUTHORITY["EPSG","7400"]]"""
    wkt = srs.ExportToPrettyWkt()

    if gdaltest.equal_srs_from_wkt( exp_wkt, wkt ) == 0:
        gdaltest.post_reason( 'did not get expected compound cs for EPSG:7400')
        return 'fail'
    # elif exp_wkt != wkt:
    #    print('warning they are equivalent, but not completely the same')
    #    print(wkt)

    return 'success'
Exemplo n.º 56
0
def osr_compd_7():

    srs_horiz = osr.SpatialReference()
    srs_horiz.ImportFromEPSG( 4326 )

    srs_vert = osr.SpatialReference()
    srs_vert.ImportFromEPSG( 5703 )
    srs_vert.SetTargetLinearUnits( 'VERT_CS', 'foot', 0.304800609601219 )

    srs = osr.SpatialReference()
    srs.SetCompoundCS( 'My Compound SRS', srs_horiz, srs_vert )

    exp_wkt = """COMPD_CS["My Compound SRS",
    GEOGCS["WGS 84",
        DATUM["WGS_1984",
            SPHEROID["WGS 84",6378137,298.257223563,
                AUTHORITY["EPSG","7030"]],
            AUTHORITY["EPSG","6326"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.0174532925199433,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4326"]],
    VERT_CS["NAVD88 height",
        VERT_DATUM["North American Vertical Datum 1988",2005,
            AUTHORITY["EPSG","5103"],
            EXTENSION["PROJ4_GRIDS","g2003conus.gtx,g2003alaska.gtx,g2003h01.gtx,g2003p01.gtx"]],
        AXIS["Up",UP],
        UNIT["foot",0.304800609601219],
        AUTHORITY["EPSG","5703"]]]"""
        
    wkt = srs.ExportToPrettyWkt() 

    if gdaltest.equal_srs_from_wkt( exp_wkt, wkt ) == 0:
        return 'fail'

    return 'success'
Exemplo n.º 57
0
def hfa_rotated_write():

    # make sure we aren't preserving info in .aux.xml file
    try:
        os.remove( 'tmp/rot.img.aux.xml' )
    except:
        pass
    
    drv = gdal.GetDriverByName('HFA')
    ds = drv.Create( 'tmp/rot.img', 100, 150, 1, gdal.GDT_Byte )
    
    check_gt = ( 11856857.07898215, 0.895867662235625, 0.02684252936279331,
                 7041861.472946444, 0.01962103617166367, -0.9007880319529181)

    expected_wkt = """PROJCS["NAD83 / Virginia North",
    GEOGCS["NAD83",
        DATUM["North_American_Datum_1983",
            SPHEROID["GRS 1980",6378137,298.257222101,
                AUTHORITY["EPSG","7019"]],
            AUTHORITY["EPSG","6269"]],
        PRIMEM["Greenwich",0,
            AUTHORITY["EPSG","8901"]],
        UNIT["degree",0.01745329251994328,
            AUTHORITY["EPSG","9122"]],
        AUTHORITY["EPSG","4269"]],
    PROJECTION["Lambert_Conformal_Conic_2SP"],
    PARAMETER["standard_parallel_1",39.2],
    PARAMETER["standard_parallel_2",38.03333333333333],
    PARAMETER["latitude_of_origin",37.66666666666666],
    PARAMETER["central_meridian",-78.5],
    PARAMETER["false_easting",11482916.66666667],
    PARAMETER["false_northing",6561666.666666667],
    UNIT["us_survey_feet",0.3048006096012192]]"""

    # For some reason we are now no longer able to preserve the authority
    # nodes and other info in the above, so we revert to the following.
    # (see #2755 for followup).

    expected_wkt = """PROJCS["NAD83_Virginia_North",GEOGCS["GCS_North_American_1983",DATUM["North_American_Datum_1983",SPHEROID["GRS_1980",6378137,298.257222101]],PRIMEM["Greenwich",0],UNIT["Degree",0.017453292519943295]],PROJECTION["Lambert_Conformal_Conic_2SP"],PARAMETER["standard_parallel_1",39.2],PARAMETER["standard_parallel_2",38.03333333333333],PARAMETER["latitude_of_origin",37.66666666666666],PARAMETER["central_meridian",-78.5],PARAMETER["false_easting",11482916.66666667],PARAMETER["false_northing",6561666.666666667],PARAMETER["scale_factor",1.0],UNIT["Foot_US",0.30480060960121924]]"""
    
    ds.SetGeoTransform( check_gt )
    ds.SetProjection( expected_wkt )

    ds = None
    
    ds = gdal.Open( 'tmp/rot.img' )
    gt_epsilon = (abs(check_gt[1])+abs(check_gt[2])) / 100.0
                
    new_gt = ds.GetGeoTransform()
    for i in range(6):
        if abs(new_gt[i]-check_gt[i]) > gt_epsilon:
            print('')
            print('old = ', check_gt)
            print('new = ', new_gt)
            gdaltest.post_reason( 'Geotransform differs.' )
            return 'fail'

    wkt = ds.GetProjection()
    if not gdaltest.equal_srs_from_wkt( expected_wkt, wkt ):
        return 'fail'
    
    ds = None

    gdal.GetDriverByName( 'HFA' ).Delete( 'tmp/rot.img' )

    return 'success'