本文整理汇总了Python中ecohydrolib.metadata.GenericMetadata.writeStudyAreaEntry方法的典型用法代码示例。如果您正苦于以下问题:Python GenericMetadata.writeStudyAreaEntry方法的具体用法?Python GenericMetadata.writeStudyAreaEntry怎么用?Python GenericMetadata.writeStudyAreaEntry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ecohydrolib.metadata.GenericMetadata
的用法示例。
在下文中一共展示了GenericMetadata.writeStudyAreaEntry方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_delete
# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import writeStudyAreaEntry [as 别名]
def test_delete(self):
GenericMetadata.writeManifestEntry(self.context, "key1", "value_one")
manifest = GenericMetadata.readManifestEntries(self.context)
self.assertTrue(manifest["key1"] == "value_one")
GenericMetadata.deleteManifestEntry(self.context, "key1")
manifest = GenericMetadata.readManifestEntries(self.context)
self.assertTrue(not 'key1' in manifest)
GenericMetadata.writeStudyAreaEntry(self.context, "key1", "value_one")
studyArea = GenericMetadata.readStudyAreaEntries(self.context)
self.assertTrue(studyArea["key1"] == "value_one")
GenericMetadata.deleteStudyAreaEntry(self.context, 'key1')
studyArea = GenericMetadata.readStudyAreaEntries(self.context)
self.assertTrue(not 'key1' in studyArea)
GenericMetadata.writeClimatePointEntry(self.context, "key1", "value_one")
climatePoint = GenericMetadata.readClimatePointEntries(self.context)
self.assertTrue(climatePoint["key1"] == "value_one")
GenericMetadata.deleteClimatePointEntry(self.context, 'key1')
climatePoint = GenericMetadata.readClimatePointEntries(self.context)
self.assertTrue(not 'key1' in climatePoint)
GenericMetadata.writeClimateGridEntry(self.context, "key1", "value_one")
climateGrid = GenericMetadata.readClimateGridEntries(self.context)
self.assertTrue(climateGrid["key1"] == "value_one")
GenericMetadata.deleteClimateGridEntry(self.context, 'key1')
climateGrid = GenericMetadata.readClimateGridEntries(self.context)
self.assertTrue(not 'key1' in climateGrid)
# Delete and empty entry
GenericMetadata.deleteClimateGridEntry(self.context, "not_in_store")
示例2: test_write_and_read
# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import writeStudyAreaEntry [as 别名]
def test_write_and_read(self):
GenericMetadata.writeManifestEntry(self.context, "key1", "value_one")
GenericMetadata.writeManifestEntry(self.context, "key2", "value_two")
manifest = GenericMetadata.readManifestEntries(self.context)
self.assertTrue(manifest["key1"] == "value_one")
GenericMetadata.writeStudyAreaEntry(self.context, "key1", "value_one")
GenericMetadata.writeStudyAreaEntry(self.context, "key2", "value_two")
studyArea = GenericMetadata.readStudyAreaEntries(self.context)
self.assertTrue(studyArea["key1"] == "value_one")
GenericMetadata.writeClimatePointEntry(self.context, "key1", "value_one")
GenericMetadata.writeClimatePointEntry(self.context, "key2", "value_two")
climatePoint = GenericMetadata.readClimatePointEntries(self.context)
self.assertTrue(climatePoint["key1"] == "value_one")
GenericMetadata.writeClimateGridEntry(self.context, "key1", "value_one")
GenericMetadata.writeClimateGridEntry(self.context, "key2", "value_two")
climateGrid = GenericMetadata.readClimateGridEntries(self.context)
self.assertTrue(climateGrid["key1"] == "value_one")
示例3: test_delete
# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import writeStudyAreaEntry [as 别名]
def test_delete(self):
GenericMetadata.writeManifestEntry(self.context, "key1", "value_one")
manifest = GenericMetadata.readManifestEntries(self.context)
self.assertTrue(manifest["key1"] == "value_one")
GenericMetadata.deleteManifestEntry(self.context, "key1")
manifest = GenericMetadata.readManifestEntries(self.context)
self.assertTrue(not 'key1' in manifest)
GenericMetadata.writeStudyAreaEntry(self.context, "key1", "value_one")
studyArea = GenericMetadata.readStudyAreaEntries(self.context)
self.assertTrue(studyArea["key1"] == "value_one")
GenericMetadata.deleteStudyAreaEntry(self.context, 'key1')
studyArea = GenericMetadata.readStudyAreaEntries(self.context)
self.assertTrue(not 'key1' in studyArea)
GenericMetadata.writeClimatePointEntry(self.context, "key1", "value_one")
climatePoint = GenericMetadata.readClimatePointEntries(self.context)
self.assertTrue(climatePoint["key1"] == "value_one")
GenericMetadata.deleteClimatePointEntry(self.context, 'key1')
climatePoint = GenericMetadata.readClimatePointEntries(self.context)
self.assertTrue(not 'key1' in climatePoint)
GenericMetadata.writeClimateGridEntry(self.context, "key1", "value_one")
climateGrid = GenericMetadata.readClimateGridEntries(self.context)
self.assertTrue(climateGrid["key1"] == "value_one")
GenericMetadata.deleteClimateGridEntry(self.context, 'key1')
climateGrid = GenericMetadata.readClimateGridEntries(self.context)
self.assertTrue(not 'key1' in climateGrid)
# Delete and empty entry
GenericMetadata.deleteClimateGridEntry(self.context, "not_in_store")
GenericMetadata.writeHydroShareEntry(self.context, "resource_id", "fae3688aa1354fb2a558380669229a66")
hydroshare = GenericMetadata.readHydroShareEntries(self.context)
self.assertTrue(hydroshare["resource_id"] == "fae3688aa1354fb2a558380669229a66")
GenericMetadata.deleteHydroShareEntry(self.context, "resource_id")
hydroshare = GenericMetadata.readHydroShareEntries(self.context)
self.assertTrue(not 'resource_id' in hydroshare)
示例4: test_write_and_read
# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import writeStudyAreaEntry [as 别名]
def test_write_and_read(self):
GenericMetadata.writeManifestEntry(self.context, "key1", "value_one")
GenericMetadata.writeManifestEntry(self.context, "key2", "value_two")
manifest = GenericMetadata.readManifestEntries(self.context)
self.assertTrue(manifest["key1"] == "value_one")
GenericMetadata.writeStudyAreaEntry(self.context, "key1", "value_one")
GenericMetadata.writeStudyAreaEntry(self.context, "key2", "value_two")
studyArea = GenericMetadata.readStudyAreaEntries(self.context)
self.assertTrue(studyArea["key1"] == "value_one")
GenericMetadata.writeClimatePointEntry(self.context, "key1", "value_one")
GenericMetadata.writeClimatePointEntry(self.context, "key2", "value_two")
climatePoint = GenericMetadata.readClimatePointEntries(self.context)
self.assertTrue(climatePoint["key1"] == "value_one")
GenericMetadata.writeClimateGridEntry(self.context, "key1", "value_one")
GenericMetadata.writeClimateGridEntry(self.context, "key2", "value_two")
climateGrid = GenericMetadata.readClimateGridEntries(self.context)
self.assertTrue(climateGrid["key1"] == "value_one")
GenericMetadata.writeHydroShareEntry(self.context, "resource_id", "fae3688aa1354fb2a558380669229a66")
hydroshare = GenericMetadata.readHydroShareEntries(self.context)
self.assertTrue(hydroshare["resource_id"] == "fae3688aa1354fb2a558380669229a66")
示例5: getLocationForStreamGageByGageSourceFea
# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import writeStudyAreaEntry [as 别名]
else:
reachcode = measure = "Gage not found"
result = getLocationForStreamGageByGageSourceFea(context.config, args.gageid)
if result:
gage_lat = result[1]
gage_lon = result[0]
else:
gage_lat = gage_lon = "Gage not found"
# Write gage coordinates to a shapefile in the project directory
shpFilename = writeCoordinatePairsToPointShapefile(context.projectDir, "gage",
"gage_id", [args.gageid], [(gage_lon, gage_lat)])
# Write study area metadata
GenericMetadata.writeStudyAreaEntry(context, 'gage_id_attr', 'gage_id')
GenericMetadata.writeStudyAreaEntry(context, 'gage_id', args.gageid)
GenericMetadata.writeStudyAreaEntry(context, 'nhd_gage_reachcode', reachcode)
GenericMetadata.writeStudyAreaEntry(context, 'nhd_gage_measure_pct', measure)
GenericMetadata.writeStudyAreaEntry(context, 'gage_lat_wgs84', gage_lat)
GenericMetadata.writeStudyAreaEntry(context, 'gage_lon_wgs84', gage_lon)
# Write provenance
asset = AssetProvenance(GenericMetadata.MANIFEST_SECTION)
asset.name = 'gage'
asset.dcIdentifier = shpFilename
asset.dcSource = 'http://www.horizon-systems.com/NHDPlus/NHDPlusV2_home.php'
asset.dcTitle = 'Streamflow gage'
asset.dcPublisher = 'USGS'
asset.dcDescription = cmdline
asset.writeToMetadata(context)
示例6: resampleRaster
# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import writeStudyAreaEntry [as 别名]
demResolutionX = demSrs[0]
demResolutionY = demSrs[1]
# Resample DEM to target srs and resolution
if resample:
sys.stdout.write("Resampling DEM to resolution %.2f x %.2f..." % (demResolutionX, demResolutionY) )
sys.stdout.flush()
resampleRaster(context.config, context.projectDir, tmpDEMFilepath, demFilename, \
s_srs=t_srs, t_srs=t_srs, \
trX=demResolutionX, trY=demResolutionY)
sys.stdout.write('done\n')
else:
shutil.move(tmpDEMFilepath, demFilepath)
# Write metadata
GenericMetadata.writeStudyAreaEntry(context, 'dem_res_x', demResolutionX)
GenericMetadata.writeStudyAreaEntry(context, 'dem_res_y', demResolutionY)
GenericMetadata.writeStudyAreaEntry(context, 'dem_srs', t_srs)
# Get rows and columns for DEM
(columns, rows) = getDimensionsForRaster(demFilepath)
GenericMetadata.writeStudyAreaEntry(context, 'dem_columns', columns)
GenericMetadata.writeStudyAreaEntry(context, 'dem_rows', rows)
# Write provenance
asset = AssetProvenance(GenericMetadata.MANIFEST_SECTION)
asset.name = 'dem'
asset.dcIdentifier = demFilename
asset.dcSource = demURL
asset.dcTitle = 'Digital Elevation Model'
asset.dcPublisher = 'GeoBrain'
示例7: run
# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import writeStudyAreaEntry [as 别名]
def run(self, *args, **kwargs):
""" Run the command: Acquire USGS DEM data.
Arguments:
coverage -- string Source dataset from which DEM tile should be extracted.
outfile -- string The name of the DEM file to be written. File extension ".tif" will be added.
demResolution list<float>[2] Two floating point numbers representing the desired X and Y output resolution of soil property raster maps; unit: meters.
srs -- string Target spatial reference system of output, in EPSG:num format.
verbose -- boolean Produce verbose output. Default: False.
overwrite -- boolean Overwrite existing output. Default: False.
"""
coverage = kwargs.get('coverage', self.DEFAULT_COVERAGE)
outfile = kwargs.get('outfile', None)
demResolution = kwargs.get('demResolution', None)
srs = kwargs.get('srs', None)
verbose = kwargs.get('verbose', False)
overwrite = kwargs.get('overwrite', False)
self.checkMetadata()
bbox = bboxFromString(self.studyArea['bbox_wgs84'])
if not outfile:
outfile = 'DEM'
demFilename = "%s.tif" % (outfile)
demResolutionX = demResolutionY = None
if demResolution:
demResolutionX = demResolution[0]
demResolutionY = demResolution[1]
if srs:
if not isValidSrs(srs):
msg = "ERROR: '%s' is not a valid spatial reference. Spatial reference must be of the form 'EPSG:XXXX', e.g. 'EPSG:32617'. For more information, see: http://www.spatialreference.org/" % (srs,)
raise RunException(msg)
else:
# Default for UTM
(centerLon, centerLat) = calculateBoundingBoxCenter(bbox)
(utmZone, isNorth) = getUTMZoneFromCoordinates(centerLon, centerLat)
srs = getEPSGStringForUTMZone(utmZone, isNorth)
try:
(dataFetched, urlFetched) = ecohydrolib.usgs.demwcs.getDEMForBoundingBox(self.context.config,
self.context.projectDir,
demFilename,
bbox,
srs,
coverage=coverage,
resx=demResolutionX,
resy=demResolutionY,
scale=0.01,
overwrite=overwrite,
verbose=verbose,
outfp=self.outfp)
except Exception as e:
traceback.print_exc(file=self.outfp)
raise RunException(e)
if not dataFetched:
raise RunException("Failed to download DEM data from URL {0}".format(urlFetched))
# Write metadata entries
cmdline = GenericMetadata.getCommandLine()
# Write metadata
demFilepath = os.path.join(self.context.projectDir, demFilename)
demSrs = getSpatialReferenceForRaster(demFilepath)
GenericMetadata.writeStudyAreaEntry(self.context, 'dem_res_x', demSrs[0])
GenericMetadata.writeStudyAreaEntry(self.context, 'dem_res_y', demSrs[1])
GenericMetadata.writeStudyAreaEntry(self.context, 'dem_srs', srs)
# Get rows and columns for DEM
(columns, rows) = getDimensionsForRaster(demFilepath)
GenericMetadata.writeStudyAreaEntry(self.context, 'dem_columns', columns)
GenericMetadata.writeStudyAreaEntry(self.context, 'dem_rows', rows)
# Write provenance
asset = AssetProvenance(GenericMetadata.MANIFEST_SECTION)
asset.name = 'dem'
asset.dcIdentifier = demFilename
asset.dcSource = urlFetched
asset.dcTitle = "Digital Elevation Model ({0})".format(coverage)
asset.dcPublisher = 'U.S. Geological Survey'
asset.dcDescription = cmdline
asset.processingNotes = "Elevation values rescaled from centimeters to meters. "
asset.processingNotes += "Spatial grid resampled to {srs} with X resolution {xres} and Y resolution {yres}."
asset.processingNotes = asset.processingNotes.format(srs=srs,
xres=demSrs[0],
yres=demSrs[1])
asset.writeToMetadata(self.context)
# Write processing history
GenericMetadata.appendProcessingHistoryItem(self.context, cmdline)
示例8: isCoordinatePairInBoundingBox
# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import writeStudyAreaEntry [as 别名]
args.idAttribute, gageIDs)
gage_lon = coords[0][0]
gage_lat = coords[0][1]
coordinates = (gage_lon, gage_lat)
# Ensure gage coordinates are within bounding box
if not isCoordinatePairInBoundingBox(bbox, coordinates):
sys.exit("Gage coordinates %s, %s do not appear to lie within bounding box %s, %s, %s, %s" %
( str(gage_lon), str(gage_lat), str(bbox['minX']), str(bbox['minY']), str(bbox['maxX']), str(bbox['maxY']) ) )
shpFilename = writeCoordinatePairsToPointShapefile(context.projectDir, outfile, "gage_id", gageIDs, [coordinates])
sys.stdout.write('done\n')
# Write metadata
GenericMetadata.writeStudyAreaEntry(context, 'gage_id_attr', 'gage_id')
GenericMetadata.writeStudyAreaEntry(context, 'gage_id', args.idValue)
GenericMetadata.writeStudyAreaEntry(context, 'gage_lat_wgs84', gage_lat)
GenericMetadata.writeStudyAreaEntry(context, 'gage_lon_wgs84', gage_lon)
# Write provenance
asset = AssetProvenance(GenericMetadata.MANIFEST_SECTION)
asset.name = 'gage'
asset.dcIdentifier = shpFilename
asset.dcSource = "file://%s" % (inGagePath,)
asset.dcTitle = 'Streamflow gage'
asset.dcPublisher = publisher
asset.dcDescription = cmdline
asset.writeToMetadata(context)
# Write processing history
示例9: extractTileFromRasterByRasterExtent
# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import writeStudyAreaEntry [as 别名]
sys.stdout.write('Extracting tile from local NLCD data...')
sys.stdout.flush()
extractTileFromRasterByRasterExtent(context.config, context.projectDir, demFilepath, nlcdRaster, tileFilename)
sys.stdout.write('done\n')
else:
# Download NLCD from WCS
sys.stdout.write("Downloading NLCD via WCS from %s..." % (HOST,) )
sys.stdout.flush()
(returnCode, nlcdURL) = getNLCDForBoundingBox(context.config, context.projectDir, tileFilename, bbox=bbox,
resx=outputrasterresolutionX, resy=outputrasterresolutionY,
coverage='NLCD2006', srs=srs)
assert(returnCode)
sys.stdout.write('done\n')
# Write metadata
GenericMetadata.writeStudyAreaEntry(context, "landcover_type", "NLCD2006")
# Write provenance
asset = AssetProvenance(GenericMetadata.MANIFEST_SECTION)
asset.name = 'landcover'
asset.dcIdentifier = tileFilename
asset.dcSource = nlcdURL
asset.dcTitle = 'The National Landcover Database 2006'
asset.dcPublisher = 'USGS'
asset.dcDescription = cmdline
asset.writeToMetadata(context)
# Write processing history
GenericMetadata.appendProcessingHistoryItem(context, cmdline)
示例10: resampleRaster
# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import writeStudyAreaEntry [as 别名]
else:
resampleRaster(context.config, context.projectDir, inDEMPath, demFilename,
s_srs, t_srs, demResolutionX, demResolutionY, args.resampleMethod)
if args.scale:
rescaleRaster(context.config, context.projectDir, demFilepathTemp, demFilename, args.scale)
os.unlink(demFilepathTemp)
sys.stdout.write('done\n')
# Get the bounding box for the DEM
bbox = getBoundingBoxForRaster(demFilepath)
# Write a shapefile for the bounding box
shpFilename = writeBboxPolygonToShapefile(bbox, context.projectDir, "studyarea")
# Write metadata
GenericMetadata.writeStudyAreaEntry(context, "bbox_wgs84", "%f %f %f %f" % (bbox['minX'], bbox['minY'], bbox['maxX'], bbox['maxY']))
# Get spatial metadata for DEM
demSpatialMetadata = getSpatialReferenceForRaster(demFilepath)
GenericMetadata.writeStudyAreaEntry(context, "dem_res_x", demSpatialMetadata[0])
GenericMetadata.writeStudyAreaEntry(context, "dem_res_y", demSpatialMetadata[1])
GenericMetadata.writeStudyAreaEntry(context, "dem_srs", demSpatialMetadata[5])
# Get rows and columns for DEM
demFilepath = os.path.join(context.projectDir, demFilename)
(columns, rows) = getDimensionsForRaster(demFilepath)
GenericMetadata.writeStudyAreaEntry(context, "dem_columns", columns)
GenericMetadata.writeStudyAreaEntry(context, "dem_rows", rows)
# Write provenance
inputDEMURL = "file://%s" % (inDEMPath,)
示例11: run
# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import writeStudyAreaEntry [as 别名]
def run(self, *args, **kwargs):
""" Run the command: Acquire NLCD data from USGS WCS web service.
Arguments:
lctype -- string Source dataset from which NLCD tile should be extracted.
outfile -- string The name of the NLCD file to be written. File extension ".tif" will be added.
verbose -- boolean Produce verbose output. Default: False.
overwrite -- boolean Overwrite existing output. Default: False.
"""
lctype = kwargs.get('lctype', DEFAULT_LC_TYPE)
outfile = kwargs.get('outfile', None)
verbose = kwargs.get('verbose', False)
overwrite = kwargs.get('overwrite', False)
if lctype not in ecohydrolib.usgs.nlcdwcs.LC_TYPE_TO_COVERAGE:
msg = "Land cover type {lctype} is not in the list of supported types {types}"
raise CommandException(msg.format(lctype=lctype,
types=ecohydrolib.usgs.nlcdwcs.LC_TYPE_TO_COVERAGE))
self.checkMetadata()
demFilename = self.manifest['dem']
demFilepath = os.path.join(self.context.projectDir, demFilename)
demFilepath = os.path.abspath(demFilepath)
bbox = getRasterExtentAsBbox(demFilepath)
if not outfile:
outfile = 'NLCD'
try:
(resp, urlFetched, fname) = getNLCDRasterDataForBoundingBox(self.context.config,
self.context.projectDir,
bbox,
coverage=LC_TYPE_TO_COVERAGE[lctype],
filename=outfile,
srs=self.studyArea['dem_srs'],
resx=self.studyArea['dem_res_x'],
resy=self.studyArea['dem_res_y'],
overwrite=overwrite,
verbose=verbose,
outfp=self.outfp)
except Exception as e:
traceback.print_exc(file=self.outfp)
raise RunException(e)
if not resp:
raise RunException("Failed to download NLCD data from URL {0}".format(urlFetched))
# Write metadata entries
cmdline = GenericMetadata.getCommandLine()
GenericMetadata.writeStudyAreaEntry(self.context, "landcover_type", lctype)
# Write provenance
asset = AssetProvenance(GenericMetadata.MANIFEST_SECTION)
asset.name = 'landcover'
asset.dcIdentifier = fname
asset.dcSource = urlFetched
asset.dcTitle = "The National Landcover Database: {0}".format(lctype)
asset.dcPublisher = 'USGS'
asset.dcDescription = cmdline
asset.writeToMetadata(self.context)
# Write processing history
GenericMetadata.appendProcessingHistoryItem(self.context, cmdline)
示例12: Context
# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import writeStudyAreaEntry [as 别名]
# Handle command line options
parser = argparse.ArgumentParser(description='Get bounding box from study area shapefile')
parser.add_argument('-p', '--projectDir', dest='projectDir', required=True,
help='The directory to which metadata, intermediate, and final files should be saved')
parser.add_argument('-b', '--buffer', dest='buffer', required=False,
help='Number of WGS84 degrees by which to buffer the bounding box')
args = parser.parse_args()
cmdline = GenericMetadata.getCommandLine()
context = Context(args.projectDir, None)
buffer = 0.01
if args.buffer:
buffer = float(args.buffer)
# Get name of study area shapefile
manifest = GenericMetadata.readManifestEntries(context)
shapefileName = manifest['study_area_shapefile']
shapefilePath = os.path.join(context.projectDir, shapefileName)
if not os.access(shapefilePath, os.R_OK):
raise IOError(errno.EACCES, "Unable to read shapefile %s" %
args.shapefile)
# Get bounding box, buffer by about 1 km
bbox = getBoundingBoxForShapefile(shapefilePath, buffer=buffer)
GenericMetadata.writeStudyAreaEntry(context, "bbox_wgs84", "%f %f %f %f" % (bbox['minX'], bbox['minY'], bbox['maxX'], bbox['maxY']))
# Write processing history
GenericMetadata.appendProcessingHistoryItem(context, cmdline)
示例13: copyRasterToGeoTIFF
# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import writeStudyAreaEntry [as 别名]
sys.stdout.write("%s..." % (processingNotes,) )
sys.stdout.flush()
copyRasterToGeoTIFF(context.config, context.projectDir, inRasterPath, rasterFilename)
sys.stdout.write('done\n')
# Make sure extent of resampled raster is the same as the extent of the DEM
newRasterMetadata = getDimensionsForRaster(rasterFilepath)
if (not force) and ( (newRasterMetadata[0] != demColumns) or (newRasterMetadata[1] != demRows) ):
# Extents to not match, roll back and bail out
os.unlink(rasterFilepath)
sys.exit(textwrap.fill("ERROR: Extent of raster dataset %s does not match extent of DEM in project directory %s. Use --force to override.") %
(rasterFilename, context.projectDir))
# Write metadata
if GenericMetadata.RASTER_TYPE_LC == args.type:
GenericMetadata.writeStudyAreaEntry(context, "landcover_type", "custom")
# Write provenance
asset = AssetProvenance(GenericMetadata.MANIFEST_SECTION)
asset.name = args.type
asset.dcIdentifier = rasterFilename
asset.dcSource = "file://%s" % (inRasterPath,)
asset.dcTitle = args.type
asset.dcPublisher = publisher
asset.dcDescription = cmdline
asset.processingNotes = processingNotes
asset.writeToMetadata(context)
# Write processing history
GenericMetadata.appendProcessingHistoryItem(context, cmdline)
示例14: getSpatialReferenceForRaster
# 需要导入模块: from ecohydrolib.metadata import GenericMetadata [as 别名]
# 或者: from ecohydrolib.metadata.GenericMetadata import writeStudyAreaEntry [as 别名]
if args.demResolution:
demResolutionX = args.demResolution[0]
demResolutionY = args.demResolution[1]
else:
demSrs = getSpatialReferenceForRaster(tmpDEMFilepath)
demResolutionX = demSrs[0]
demResolutionY = demSrs[1]
# Resample DEM to target srs and resolution
resampleRaster(context.config, context.projectDir, tmpDEMFilepath, demFilename, \
s_srs=demtile.DEFAULT_CRS, t_srs=t_srs, \
trX=demResolutionX, trY=demResolutionY)
# Write metadata
GenericMetadata.writeStudyAreaEntry(context, "dem_res_x", demResolutionX)
GenericMetadata.writeStudyAreaEntry(context, "dem_res_y", demResolutionY)
GenericMetadata.writeStudyAreaEntry(context, "dem_srs", t_srs)
# Get rows and columns for DEM
(columns, rows) = getDimensionsForRaster(demFilepath)
GenericMetadata.writeStudyAreaEntry(context, "dem_columns", columns)
GenericMetadata.writeStudyAreaEntry(context, "dem_rows", rows)
# Write provenance
asset = AssetProvenance(GenericMetadata.MANIFEST_SECTION)
asset.name = 'dem'
asset.dcIdentifier = demFilename
asset.dcSource = 'http://eros.usgs.gov/#/Find_Data/Products_and_Data_Available/gtopo30/hydro/namerica'
asset.dcTitle = 'Digital Elevation Model from HYDRO1k'
asset.dcPublisher = 'USGS'