示例#1
0
def test_wmts():
    # Find out what a WMTS has to offer. Service metadata:
    from owslib.wmts import WebMapTileService
    wmts = WebMapTileService(SERVICE_URL)
    assert wmts.identification.type == 'OGC WMTS'
    assert wmts.identification.version == '1.0.0'
    assert wmts.identification.title == 'NASA Global Imagery Browse Services for EOSDIS'
    bytearray(wmts.identification.abstract, 'utf-8')
    bytearray(b'Near real time imagery from multiple NASA instruments')
    assert wmts.identification.keywords == ['World', 'Global']
    # Service Provider:
    assert wmts.provider.name == 'National Aeronautics and Space Administration'
    assert wmts.provider.url == 'https://earthdata.nasa.gov/'
    # Available Layers:
    assert len(wmts.contents.keys()) > 0
    assert sorted(list(wmts.contents))[0] == 'AIRS_All_Sky_Outgoing_Longwave_Radiation_Daily_Day'
    # Fetch a tile (using some defaults):
    tile = wmts.gettile(layer='MODIS_Terra_CorrectedReflectance_TrueColor',
                        tilematrixset='EPSG4326_250m', tilematrix='0',
                        row=0, column=0, format="image/jpeg")
    out = open(scratch_file('nasa_modis_terra_truecolour.jpg'), 'wb')
    bytes_written = out.write(tile.read())
    out.close()
    # Test styles for several layers
    # TODO: fix dict order
    # assert wmts.contents['MLS_SO2_147hPa_Night'].styles == {'default': {'isDefault': True, 'title': 'default'}}
    assert wmts.contents['MLS_SO2_147hPa_Night'].styles['default']['isDefault'] is True
    # assert wmts.contents['MLS_SO2_147hPa_Night'].styles == {'default': {'isDefault': True, 'title': 'default'}}
    assert wmts.contents['MLS_SO2_147hPa_Night'].styles['default']['isDefault'] is True
示例#2
0
def test_wmts():
    # Find out what a WMTS has to offer. Service metadata:
    from owslib.wmts import WebMapTileService
    wmts = WebMapTileService(SERVICE_URL)
    assert wmts.identification.type == 'OGC WMTS'
    assert wmts.identification.version == '1.0.0'
    assert wmts.identification.title == 'NASA Global Imagery Browse Services for EOSDIS'
    bytearray(wmts.identification.abstract, 'utf-8')
    bytearray(b'Near real time imagery from multiple NASA instruments')
    assert wmts.identification.keywords == ['World', 'Global']
    # Service Provider:
    assert wmts.provider.name == 'National Aeronautics and Space Administration'
    assert wmts.provider.url == 'https://earthdata.nasa.gov/'
    # Available Layers:
    assert len(wmts.contents.keys()) > 0
    assert sorted(list(wmts.contents))[0] == 'AIRS_CO_Total_Column_Day'
    # Fetch a tile (using some defaults):
    tile = wmts.gettile(layer='MODIS_Terra_CorrectedReflectance_TrueColor',
                        tilematrixset='EPSG4326_250m',
                        tilematrix='0',
                        row=0,
                        column=0,
                        format="image/jpeg")
    out = open(scratch_file('nasa_modis_terra_truecolour.jpg'), 'wb')
    bytes_written = out.write(tile.read())
    out.close()
    # Test styles for several layers
    # TODO: fix dict order
    # assert wmts.contents['MLS_SO2_147hPa_Night'].styles == {'default': {'isDefault': True, 'title': 'default'}}
    assert wmts.contents['MLS_SO2_147hPa_Night'].styles['default'][
        'isDefault'] is True
    # assert wmts.contents['MLS_SO2_147hPa_Night'].styles == {'default': {'isDefault': True, 'title': 'default'}}
    assert wmts.contents['MLS_SO2_147hPa_Night'].styles['default'][
        'isDefault'] is True
示例#3
0
def test_wmts_rest_only():
    # ServiceMetadata
    wmts = WebMapTileService(SERVICE_URL)
    assert wmts.identification.type == 'OGC WMTS'
    assert wmts.identification.version == '1.0.0'
    assert wmts.identification.title == 'WMTS-Testserver DOP80'
    # Content
    assert sorted(list(wmts.contents)) == ['dop80']
    # RESTful WMTS
    assert wmts.restonly
    resource = wmts.buildTileResource(layer='dop80',
                                      tilematrixset='webmercator',
                                      tilematrix='11',
                                      row='706',
                                      column='1089')
    assert resource == 'http://geoserv.weichand.de/mapproxy/wmts/dop80/webmercator/11/1089/706.png'

    tile = wmts.gettile(layer='dop80',
                        tilematrixset='webmercator',
                        tilematrix='11',
                        row='706',
                        column='1089')
    out = open(scratch_file('bvv_bayern_dop80.png'), 'wb')
    bytes_written = out.write(tile.read())
    out.close()
示例#4
0
def test_tms():
    # Find out what a TMS has to offer. Service metadata:
    from owslib.tms import TileMapService
    tms = TileMapService(SERVICE_URL)

    # Fetch a tile (using some defaults):
    tile = tms.gettile(7, 7, 4, title='brtachtergrondkaart', srs='EPSG:28992', mimetype='image/png')
    out = open(scratch_file('brtachtergrondkaart.png'), 'wb')
    out.write(tile.read())
    out.close()
示例#5
0
def test_wcs_200():
    """
    Web Coverage Service
    WCS Version 2.0.x

    rewritten doctest/wcs_200.txt
    """
    wcs = WebCoverageService(SERVICE_URL, version="2.0.1")
    assert wcs.version == '2.0.1'
    assert wcs.url == SERVICE_URL
    assert wcs.identification.title == 'rasdaman'
    assert wcs.identification.service == 'OGC WCS'
    assert wcs.provider.name == 'Jacobs University Bremen'
    assert 'AvgLandTemp' in wcs.contents.keys()
    assert len(wcs.contents.keys()) >= 20
    cvg = wcs.contents['AvgLandTemp']
    assert cvg.boundingboxes[0]['bbox'] == (-90, -180,
                                            90, 180)
    assert cvg.timelimits == [datetime.datetime(2000, 2, 1, 0, 0), datetime.datetime(2015, 6, 1, 0, 0)]
    assert cvg.timepositions[0:5] == [datetime.datetime(2000, 2, 1, 0, 0), datetime.datetime(2000, 3, 1, 0, 0),
                                      datetime.datetime(2000, 4, 1, 0, 0), datetime.datetime(2000, 5, 1, 0, 0),
                                      datetime.datetime(2000, 6, 1, 0, 0)]
    assert cvg.supportedFormats == ['application/gml+xml', 'image/jpeg', 'image/png', 'image/tiff', 'image/bmp',
                                    'image/jp2', 'application/netcdf', 'text/csv', 'application/json',
                                    'application/dem', 'application/x-ogc-dted', 'application/x-ogc-ehdr',
                                    'application/x-ogc-elas', 'application/x-ogc-envi', 'application/x-ogc-ers',
                                    'application/x-ogc-fit', 'application/x-ogc-fits', 'image/gif',
                                    'application/x-netcdf-gmt', 'application/x-ogc-gs7bg', 'application/x-ogc-gsag',
                                    'application/x-ogc-gsbg', 'application/x-ogc-gta', 'application/x-ogc-hf2',
                                    'application/x-erdas-hfa', 'application/x-ogc-ida', 'application/x-ogc-ingr',
                                    'application/x-ogc-isis2', 'application/x-erdas-lan', 'application/x-ogc-mff2',
                                    'application/x-ogc-nitf', 'application/x-ogc-paux', 'application/x-ogc-pcidsk',
                                    'application/x-ogc-pcraster', 'application/x-ogc-pdf', 'application/x-ogc-pnm',
                                    'text/x-r', 'application/x-ogc-rmf', 'image/x-sgi', 'application/x-ogc-vrt',
                                    'image/xpm', 'application/x-ogc-zmap']
    assert cvg.grid.axislabels == ['Lat', 'Long', 'ansi']
    assert cvg.grid.dimension == 3
    assert cvg.grid.lowlimits == ['0', '0', '0']
    assert cvg.grid.highlimits == ['1799', '3599', '184']
    covID = 'AvgLandTemp'
    time_subset = ("ansi", "2000-02-01T00:00:00Z")
    lat_subset = ('Lat', 40, 50)
    long_subset = ('Long', -10, 0)
    formatType = 'application/netcdf'
    output = wcs.getCoverage(identifier=[covID], format=formatType, subsets=[long_subset, lat_subset, time_subset])
    f = open(scratch_file('test_wcs_200.nc'), 'wb')
    bytes_written = f.write(output.read())
    f.close()
示例#6
0
def test_wcs_idee():
    """
    COWS Web Coverage Service
    WCS Version 1.0.0

    rewritten doctest/wcs_idee.txt
    """
    wcs = WebCoverageService(SERVICE_URL)
    assert wcs.version == '1.0.0'
    assert wcs.url == SERVICE_URL
    assert wcs.identification.title == 'WCS UTM30N - MDT Peninsula y Baleares'
    assert wcs.identification.service == 'IDEE-WCS-UTM30N'
    assert wcs.provider.name == u'Instituto Geogr\xe1fico Nacional'
    assert sorted(wcs.contents.keys()) == [
        'MDT1000_peninsula_baleares',
        'MDT1000_peninsula_baleares_aspecto',
        'MDT1000_peninsula_baleares_pendientes',
        'MDT25_peninsula_ZIP',
        'MDT25_peninsula_aspecto',
        'MDT25_peninsula_pendientes',
        'MDT500_peninsula_baleares',
        'MDT500_peninsula_baleares_aspecto',
        'MDT500_peninsula_baleares_pendientes',
        'MDT_peninsula_baleares',
        'MDT_peninsula_baleares_aspecto',
        'MDT_peninsula_baleares_pendientes']
    cvg = wcs['MDT25_peninsula_pendientes']
    assert cvg.title == 'MDT25 Pendientes Peninsula'
    assert cast_tuple_int_list(cvg.boundingBoxWGS84) == [-8, 35, 3, 43]
    assert cvg.timelimits == []
    assert sorted(cvg.supportedFormats) == ['AsciiGrid', 'FloatGrid_Zip', 'GeoTIFF']
    assert sorted(map(lambda x: x.getcode(), cvg.supportedCRS)) == [
        'EPSG:23028',
        'EPSG:23029',
        'EPSG:23030',
        'EPSG:23030',
        'EPSG:23031',
        'EPSG:4230',
        'EPSG:4326']
    output = wcs.getCoverage(
        identifier='MDT25_peninsula_pendientes',
        bbox=(600000, 4200000, 601000, 4201000),
        crs='EPSG:23030', format='AsciiGrid', resX=25, resY=25)
    f = open(scratch_file('test_idee.grd'), 'wb')
    bytes_written = f.write(output.read())
    f.close()
示例#7
0
def test_wcs_idee():
    """
    COWS Web Coverage Service
    WCS Version 1.0.0

    rewritten doctest/wcs_idee.txt
    """
    wcs = WebCoverageService(SERVICE_URL)
    assert wcs.version == '1.0.0'
    assert wcs.url == SERVICE_URL
    assert wcs.identification.title == 'WCS UTM30N - MDT Peninsula y Baleares'
    assert wcs.identification.service == 'IDEE-WCS-UTM30N'
    assert wcs.provider.name == u'Instituto Geogr\xe1fico Nacional'
    assert sorted(wcs.contents.keys()) == [
        'MDT1000_peninsula_baleares', 'MDT1000_peninsula_baleares_aspecto',
        'MDT1000_peninsula_baleares_pendientes', 'MDT25_peninsula_ZIP',
        'MDT25_peninsula_aspecto', 'MDT25_peninsula_pendientes',
        'MDT500_peninsula_baleares', 'MDT500_peninsula_baleares_aspecto',
        'MDT500_peninsula_baleares_pendientes', 'MDT_peninsula_baleares',
        'MDT_peninsula_baleares_aspecto', 'MDT_peninsula_baleares_pendientes'
    ]
    cvg = wcs['MDT25_peninsula_pendientes']
    assert cvg.title == 'MDT25 Pendientes Peninsula'
    assert cast_tuple_int_list(cvg.boundingBoxWGS84) == [-8, 35, 3, 43]
    assert cvg.timelimits == []
    assert sorted(
        cvg.supportedFormats) == ['AsciiGrid', 'FloatGrid_Zip', 'GeoTIFF']
    assert sorted(map(lambda x: x.getcode(), cvg.supportedCRS)) == [
        'EPSG:23028', 'EPSG:23029', 'EPSG:23030', 'EPSG:23030', 'EPSG:23031',
        'EPSG:4230', 'EPSG:4326'
    ]
    output = wcs.getCoverage(identifier='MDT25_peninsula_pendientes',
                             bbox=(600000, 4200000, 601000, 4201000),
                             crs='EPSG:23030',
                             format='AsciiGrid',
                             resX=25,
                             resY=25)
    f = open(scratch_file('test_idee.grd'), 'wb')
    bytes_written = f.write(output.read())
    f.close()
示例#8
0
def test_wcs_200():
    """
    Web Coverage Service
    WCS Version 2.0.x

    rewritten doctest/wcs_200.txt
    """
    wcs = WebCoverageService(SERVICE_URL, version="2.0.1")
    assert wcs.version == '2.0.1'
    assert wcs.url == SERVICE_URL
    assert wcs.identification.title == 'Marine Science Data Service'
    assert wcs.identification.service == 'OGC WCS'
    assert wcs.provider.name == 'Plymouth Marine Laboratory'
    assert 'OCCCI_V3_1_chlor_a_monthly' in wcs.contents.keys()
    assert len(wcs.contents.keys()) >= 29
    cvg = wcs.contents['OCCCI_V3_1_chlor_a_monthly']
    assert cvg.boundingboxes[0]['bbox'] == (-89.9999973327159,
                                            -180.00000333371918,
                                            89.9999973327159,
                                            180.00000333371918)
    assert cvg.timelimits == [
        datetime.datetime(1997, 9, 4, 0, 0),
        datetime.datetime(2016, 12, 1, 0, 0)
    ]
    assert cvg.timepositions[0:5] == [
        datetime.datetime(1997, 9, 4, 0, 0),
        datetime.datetime(1997, 10, 1, 0, 0),
        datetime.datetime(1997, 11, 1, 0, 0),
        datetime.datetime(1997, 12, 1, 0, 0),
        datetime.datetime(1998, 1, 1, 0, 0)
    ]
    assert cvg.supportedFormats == [
        'application/gml+xml', 'image/jpeg', 'image/png', 'image/tiff',
        'image/bmp', 'image/jp2', 'application/netcdf', 'text/csv',
        'application/json', 'application/dem', 'application/x-ogc-dted',
        'application/x-ogc-ehdr', 'application/x-ogc-elas',
        'application/x-ogc-envi', 'application/x-ogc-ers',
        'application/x-ogc-fit', 'application/x-ogc-fits', 'image/gif',
        'application/x-netcdf-gmt', 'application/x-ogc-gs7bg',
        'application/x-ogc-gsag', 'application/x-ogc-gsbg',
        'application/x-ogc-gta', 'application/x-ogc-hf2',
        'application/x-erdas-hfa', 'application/x-ogc-ida',
        'application/x-ogc-ingr', 'application/x-ogc-isis2',
        'application/x-erdas-lan', 'application/x-ogc-mff2',
        'application/x-ogc-nitf', 'application/x-ogc-paux',
        'application/x-ogc-pcidsk', 'application/x-ogc-pcraster',
        'application/x-ogc-pdf', 'application/x-ogc-pnm', 'text/x-r',
        'application/x-ogc-rmf', 'image/x-sgi', 'application/x-ogc-vrt',
        'image/xpm', 'application/x-ogc-zmap'
    ]
    assert cvg.grid.axislabels == ['Lat', 'Long', 'ansi']
    assert cvg.grid.dimension == 3
    assert cvg.grid.lowlimits == ['0', '0', '0']
    assert cvg.grid.highlimits == ['4319', '8639', '231']
    covID = 'OCCCI_V3_1_chlor_a_monthly'
    time_subset = ("ansi", "2004-06-01T00:00:00Z")
    lat_subset = ('Lat', 40, 50)
    long_subset = ('Long', -10, 0)
    formatType = 'application/netcdf'
    output = wcs.getCoverage(identifier=[covID],
                             format=formatType,
                             subsets=[long_subset, lat_subset, time_subset])
    f = open(scratch_file('test_wcs_200.nc'), 'wb')
    bytes_written = f.write(output.read())
    f.close()
示例#9
0
def test_wcs_200():
    """
    Web Coverage Service
    WCS Version 2.0.x

    rewritten doctest/wcs_200.txt
    """
    wcs = WebCoverageService(SERVICE_URL, version="2.0.1")
    assert wcs.version == '2.0.1'
    assert wcs.url == SERVICE_URL
    assert wcs.identification.title == 'rasdaman'
    assert wcs.identification.service == 'OGC WCS'
    assert wcs.provider.name == 'Jacobs University Bremen'
    assert 'AvgLandTemp' in wcs.contents.keys()
    assert len(wcs.contents.keys()) >= 20
    cvg = wcs.contents['AvgLandTemp']
    assert cvg.boundingboxes[0]['bbox'] == (-90, -180, 90, 180)
    assert cvg.timelimits == [
        datetime.datetime(2000, 2, 1, 0, 0),
        datetime.datetime(2015, 6, 1, 0, 0)
    ]
    assert cvg.timepositions[0:5] == [
        datetime.datetime(2000, 2, 1, 0, 0),
        datetime.datetime(2000, 3, 1, 0, 0),
        datetime.datetime(2000, 4, 1, 0, 0),
        datetime.datetime(2000, 5, 1, 0, 0),
        datetime.datetime(2000, 6, 1, 0, 0)
    ]
    assert cvg.supportedFormats == [
        'application/gml+xml', 'image/jpeg', 'image/png', 'image/tiff',
        'image/bmp', 'image/jp2', 'application/netcdf', 'text/csv',
        'application/json', 'application/dem', 'application/x-ogc-dted',
        'application/x-ogc-ehdr', 'application/x-ogc-elas',
        'application/x-ogc-envi', 'application/x-ogc-ers',
        'application/x-ogc-fit', 'application/x-ogc-fits', 'image/gif',
        'application/x-netcdf-gmt', 'application/x-ogc-gs7bg',
        'application/x-ogc-gsag', 'application/x-ogc-gsbg',
        'application/x-ogc-gta', 'application/x-ogc-hf2',
        'application/x-erdas-hfa', 'application/x-ogc-ida',
        'application/x-ogc-ingr', 'application/x-ogc-isis2',
        'application/x-erdas-lan', 'application/x-ogc-mff2',
        'application/x-ogc-nitf', 'application/x-ogc-paux',
        'application/x-ogc-pcidsk', 'application/x-ogc-pcraster',
        'application/x-ogc-pdf', 'application/x-ogc-pnm', 'text/x-r',
        'application/x-ogc-rmf', 'image/x-sgi', 'application/x-ogc-vrt',
        'image/xpm', 'application/x-ogc-zmap'
    ]
    assert cvg.grid.axislabels == ['Lat', 'Long', 'ansi']
    assert cvg.grid.dimension == 3
    assert cvg.grid.lowlimits == ['0', '0', '0']
    assert cvg.grid.highlimits == ['1799', '3599', '184']
    covID = 'AvgLandTemp'
    time_subset = ("ansi", "2000-02-01T00:00:00Z")
    lat_subset = ('Lat', 40, 50)
    long_subset = ('Long', -10, 0)
    formatType = 'application/netcdf'
    output = wcs.getCoverage(identifier=[covID],
                             format=formatType,
                             subsets=[long_subset, lat_subset, time_subset])
    f = open(scratch_file('test_wcs_200.nc'), 'wb')
    bytes_written = f.write(output.read())
    f.close()