def ogr_georss_10(): try: os.remove ('tmp/test32631.rss') except: pass srs = osr.SpatialReference() srs.ImportFromEPSG(32631) ds = ogr.GetDriverByName('GeoRSS').CreateDataSource('tmp/test32631.rss') gdal.PushErrorHandler( 'CPLQuietErrorHandler' ) try: lyr = ds.CreateLayer('georss', srs = srs) except: lyr = None gdal.PopErrorHandler() if lyr is not None: gdal.post_reason('should not have accepted EPSG:32631 with GEOM_DIALECT != GML') return 'fail' ds.Destroy() try: os.remove ('tmp/test32631.rss') except: pass ds = ogr.GetDriverByName('GeoRSS').CreateDataSource('tmp/test32631.rss', options = [ 'GEOM_DIALECT=GML' ]) lyr = ds.CreateLayer('georss', srs = srs) dst_feat = ogr.Feature( feature_def = lyr.GetLayerDefn() ) dst_feat.SetGeometry(ogr.CreateGeometryFromWkt('POINT (500000 4000000)')) if lyr.CreateFeature( dst_feat ) != 0: gdaltest.post_reason('CreateFeature failed.') return 'fail' dst_feat.Destroy() ds.Destroy() content = open('tmp/test32631.rss').read() if content.find('<georss:where><gml:Point srsName="urn:ogc:def:crs:EPSG::32631"><gml:pos>500000 4000000') == -1: print(('%s' % content)) return 'fail' return 'success'
def pcraster_2(): if gdaltest.pcraster_drv is None: return 'skip' ds = gdal.Open( 'data/ldd.map' ) gt = ds.GetGeoTransform() if gt[0] != 182140.0 or gt[1] != 10 or gt[2] != 0 \ or gt[3] != 327880.0 or gt[4] != 0 or gt[5] != -10: gdal.post_reason( 'PCRaster geotransform wrong.' ) return 'fail' band1 = ds.GetRasterBand(1) if band1.GetNoDataValue() != 255: gdal.post_reason( 'PCRaster NODATA value wrong or missing.' ) return 'fail' return 'success'
def lcp_2(): ds = gdal.Open("data/test_USGS_LFNM_Alb83.lcp") if ds.RasterCount != 8: gdal.post_reason("wrong number of bands") return "fail" metadata = [("LATITUDE", "48"), ("LINEAR_UNIT", "Meters"), ("DESCRIPTION", "")] md = ds.GetMetadata() for item in metadata: if md[item[0]] != item[1]: gdaltest.post_reason( "wrong metadataitem for dataset. md['%s']='%s', expected '%s'" % (item[0], md[item[0]], item[1]) ) return "fail" check_gt = (-1328145, 30, 0, 2961735, 0, -30) new_gt = ds.GetGeoTransform() for i in range(6): if abs(new_gt[i] - check_gt[i]) > 1e-5: print("") print("old = ", check_gt) print("new = ", new_gt) gdaltest.post_reason("Geotransform differs.") return "fail" dataPerBand = [ ( 28381, [ ("ELEVATION_UNIT", "0"), ("ELEVATION_UNIT_NAME", "Meters"), ("ELEVATION_MIN", "1064"), ("ELEVATION_MAX", "1492"), ("ELEVATION_NUM_CLASSES", "-1"), ("ELEVATION_FILE", "d:\\scratch\\dist\\79990093\\Output\\rastert_elevation_1.txt"), ], ), ( 25824, [ ("SLOPE_UNIT", "0"), ("SLOPE_UNIT_NAME", "Degrees"), ("SLOPE_MIN", "0"), ("SLOPE_MAX", "34"), ("SLOPE_NUM_CLASSES", "35"), ("SLOPE_FILE", "d:\\scratch\\dist\\79990093\\Output\\rastert_slope_1.txt"), ], ), ( 28413, [ ("ASPECT_UNIT", "2"), ("ASPECT_UNIT_NAME", "Azimuth degrees"), ("ASPECT_MIN", "0"), ("ASPECT_MAX", "357"), ("ASPECT_NUM_CLASSES", "-1"), ("ASPECT_FILE", "d:\\scratch\\dist\\79990093\\Output\\rastert_aspect_1.txt"), ], ), ( 19052, [ ("FUEL_MODEL_OPTION", "0"), ("FUEL_MODEL_OPTION_DESC", "no custom models AND no conversion file needed"), ("FUEL_MODEL_MIN", "1"), ("FUEL_MODEL_MAX", "10"), ("FUEL_MODEL_NUM_CLASSES", "5"), ("FUEL_MODEL_VALUES", "1,2,5,8,10"), ("FUEL_MODEL_FILE", "d:\\scratch\\dist\\79990093\\Output\\rastert_fuel1.txt"), ], ), ( 30164, [ ("CANOPY_COV_UNIT", "1"), ("CANOPY_COV_UNIT_NAME", "Percent"), ("CANOPY_COV_MIN", "0"), ("CANOPY_COV_MAX", "95"), ("CANOPY_COV_NUM_CLASSES", "10"), ("CANOPY_COV_FILE", "d:\\scratch\\dist\\79990093\\Output\\rastert_canopy1.txt"), ], ), ( 22316, [ ("CANOPY_HT_UNIT", "3"), ("CANOPY_HT_UNIT_NAME", "Meters x 10"), ("CANOPY_HT_MIN", "0"), ("CANOPY_HT_MAX", "375"), ("CANOPY_HT_NUM_CLASSES", "5"), ("CANOPY_HT_FILE", "d:\\scratch\\dist\\79990093\\Output\\rastert_height_1.txt"), ], ), ( 30575, [ ("CBH_UNIT", "3"), ("CBH_UNIT_NAME", "Meters x 10"), ("CBH_MIN", "0"), ("CBH_MAX", "100"), ("CBH_NUM_CLASSES", "33"), ("CBH_FILE", "d:\\scratch\\dist\\79990093\\Output\\rastert_base_1.txt"), ], ), ( 23304, [ ("CBD_UNIT", "3"), ("CBD_UNIT_NAME", "kg/m^3 x 100"), ("CBD_MIN", "0"), ("CBD_MAX", "21"), ("CBD_NUM_CLASSES", "20"), ("CBD_FILE", "d:\\scratch\\dist\\79990093\\Output\\rastert_density_1.txt"), ], ), ] for i in range(8): band = ds.GetRasterBand(i + 1) if band.Checksum() != dataPerBand[i][0]: gdaltest.post_reason( "wrong checksum for band %d. Got %d, expected %d" % (i + 1, band.Checksum(), dataPerBand[i][0]) ) return "fail" md = band.GetMetadata() for item in dataPerBand[i][1]: if md[item[0]] != item[1]: gdaltest.post_reason( "wrong metadataitem for band %d. md['%s']='%s', expected '%s'" % (i + 1, item[0], md[item[0]], item[1]) ) return "fail" ds = None return "success"
def lcp_2(): ds = gdal.Open('data/test_USGS_LFNM_Alb83.lcp') if ds.RasterCount != 8: gdal.post_reason('wrong number of bands') return 'fail' metadata = [('LATITUDE', '48'), ('LINEAR_UNIT', 'Meters'), ('DESCRIPTION', '')] md = ds.GetMetadata() for item in metadata: if md[item[0]] != item[1]: gdaltest.post_reason( 'wrong metadataitem for dataset. md[\'%s\']=\'%s\', expected \'%s\'' % (item[0], md[item[0]], item[1])) return 'fail' check_gt = (-1328145, 30, 0, 2961735, 0, -30) new_gt = ds.GetGeoTransform() for i in range(6): if abs(new_gt[i] - check_gt[i]) > 1e-5: print('') print('old = ', check_gt) print('new = ', new_gt) gdaltest.post_reason('Geotransform differs.') return 'fail' dataPerBand = [ (28381, [('ELEVATION_UNIT', '0'), ('ELEVATION_UNIT_NAME', 'Meters'), ('ELEVATION_MIN', '1064'), ('ELEVATION_MAX', '1492'), ('ELEVATION_NUM_CLASSES', '-1'), ('ELEVATION_FILE', 'd:\\scratch\\dist\\79990093\\Output\\rastert_elevation_1.txt')]), (25824, [('SLOPE_UNIT', '0'), ('SLOPE_UNIT_NAME', 'Degrees'), ('SLOPE_MIN', '0'), ('SLOPE_MAX', '34'), ('SLOPE_NUM_CLASSES', '35'), ('SLOPE_FILE', 'd:\\scratch\\dist\\79990093\\Output\\rastert_slope_1.txt') ]), (28413, [('ASPECT_UNIT', '2'), ('ASPECT_UNIT_NAME', 'Azimuth degrees'), ('ASPECT_MIN', '0'), ('ASPECT_MAX', '357'), ('ASPECT_NUM_CLASSES', '-1'), ('ASPECT_FILE', 'd:\\scratch\\dist\\79990093\\Output\\rastert_aspect_1.txt') ]), (19052, [('FUEL_MODEL_OPTION', '0'), ('FUEL_MODEL_OPTION_DESC', 'no custom models AND no conversion file needed'), ('FUEL_MODEL_MIN', '1'), ('FUEL_MODEL_MAX', '10'), ('FUEL_MODEL_NUM_CLASSES', '5'), ('FUEL_MODEL_VALUES', '1,2,5,8,10'), ('FUEL_MODEL_FILE', 'd:\\scratch\\dist\\79990093\\Output\\rastert_fuel1.txt')]), (30164, [('CANOPY_COV_UNIT', '1'), ('CANOPY_COV_UNIT_NAME', 'Percent'), ('CANOPY_COV_MIN', '0'), ('CANOPY_COV_MAX', '95'), ('CANOPY_COV_NUM_CLASSES', '10'), ('CANOPY_COV_FILE', 'd:\\scratch\\dist\\79990093\\Output\\rastert_canopy1.txt') ]), (22316, [('CANOPY_HT_UNIT', '3'), ('CANOPY_HT_UNIT_NAME', 'Meters x 10'), ('CANOPY_HT_MIN', '0'), ('CANOPY_HT_MAX', '375'), ('CANOPY_HT_NUM_CLASSES', '5'), ('CANOPY_HT_FILE', 'd:\\scratch\\dist\\79990093\\Output\\rastert_height_1.txt')]), (30575, [('CBH_UNIT', '3'), ('CBH_UNIT_NAME', 'Meters x 10'), ('CBH_MIN', '0'), ('CBH_MAX', '100'), ('CBH_NUM_CLASSES', '33'), ('CBH_FILE', 'd:\\scratch\\dist\\79990093\\Output\\rastert_base_1.txt')]), (23304, [ ('CBD_UNIT', '3'), ('CBD_UNIT_NAME', 'kg/m^3 x 100'), ('CBD_MIN', '0'), ('CBD_MAX', '21'), ('CBD_NUM_CLASSES', '20'), ('CBD_FILE', 'd:\\scratch\\dist\\79990093\\Output\\rastert_density_1.txt') ]) ] for i in range(8): band = ds.GetRasterBand(i + 1) if band.Checksum() != dataPerBand[i][0]: gdaltest.post_reason( 'wrong checksum for band %d. Got %d, expected %d' % (i + 1, band.Checksum(), dataPerBand[i][0])) return 'fail' md = band.GetMetadata() for item in dataPerBand[i][1]: if md[item[0]] != item[1]: gdaltest.post_reason( 'wrong metadataitem for band %d. md[\'%s\']=\'%s\', expected \'%s\'' % (i + 1, item[0], md[item[0]], item[1])) return 'fail' ds = None return 'success'