本文整理汇总了Python中arcpy.CheckOutExtension方法的典型用法代码示例。如果您正苦于以下问题:Python arcpy.CheckOutExtension方法的具体用法?Python arcpy.CheckOutExtension怎么用?Python arcpy.CheckOutExtension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arcpy
的用法示例。
在下文中一共展示了arcpy.CheckOutExtension方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save_to_esri_grid
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CheckOutExtension [as 别名]
def save_to_esri_grid(self, out_grid, conversion_factor=None, proj=None):
import arcpy
arcpy.env.overwriteOutput = True
arcpy.env.workspace = os.getcwd()
arcpy.CheckOutExtension('Spatial')
arcpy.env.outputCoordinateSystem = prismProj
if proj is not None:
arcpy.env.outputCoordinateSystem = proj
df = np.ma.filled(self.data, self.nodatavalue)
llx = self.originX
lly = self.originY - (self.nrow * -1 * self.pixelHeight)
point = arcpy.Point(llx, lly)
r = arcpy.NumPyArrayToRaster(df, lower_left_corner=point, x_cell_size=self.pixelWidth,
y_cell_size=-1*self.pixelHeight, value_to_nodata=self.nodatavalue)
if conversion_factor is not None:
r *= conversion_factor
r.save(out_grid)
示例2: testint_to_float
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CheckOutExtension [as 别名]
def testint_to_float(self):
_dir = os.path.join(self.testingfolder, r'testing_files\rasters')
ndvi = os.path.join(_dir, 'dh_july_ndvi')
ob = round(arcpy.Raster(ndvi).maximum, 5)
int_rst = os.path.join(_dir, 'ndvi_int')
est = os.path.join(_dir, 'ndvi_tst')
if arcpy.CheckExtension('Spatial') == 'Available':
arcpy.CheckOutExtension('Spatial')
arcpy.sa.Int(arcpy.sa.Times(ndvi, 1000000)).save(int_rst)
arcpy.CheckInExtension('Spatial')
ap.int_to_float(int_rst, est, 6)
self.assertEqual(ob, round(arcpy.Raster(est).maximum, 5))
for rast in [int_rst, est]:
try:
arcpy.Delete_management(rast)
except:pass
pass
示例3: testfill_no_data
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CheckOutExtension [as 别名]
def testfill_no_data(self):
_dir = os.path.join(self.testingfolder, r'testing_files\rasters')
ndvi = os.path.join(_dir, 'dh_july_ndvi')
est = os.path.join(_dir, 'ndvi_fill')
null = os.path.join(_dir, 'null_rst')
if arcpy.CheckExtension('Spatial') == 'Available':
ap.fill_no_data(ndvi, est, 10, 10)
arcpy.CheckOutExtension('Spatial')
arcpy.sa.IsNull(est).save(null)
self.assertEqual(arcpy.Raster(null).maximum, 0)
arcpy.CheckInExtension('Spatial')
for rast in [est, null]:
try:
arcpy.Delete_management(rast)
except:pass
pass
示例4: CheckOutNALicense
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CheckOutExtension [as 别名]
def CheckOutNALicense():
if arcpy.CheckExtension("Network") == "Available":
arcpy.CheckOutExtension("Network")
else:
arcpy.AddError("You must have a Network Analyst license to use this tool.")
raise CustomError
示例5: int_to_float
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CheckOutExtension [as 别名]
def int_to_float(raster, out_raster, decimals):
"""Convert an Integer Raster to a Float Raster
*** Requires spatial analyst extension ***
E.g., for a cell with a value of 45750, using this tool with 3
decimal places will give this cell a value of 45.750
Required:
raster -- input integer raster
out_raster -- new float raster
decimals -- number of places to to move decimal for each cell
Example:
>>> convertIntegerToFloat(r'C:\Temp\ndvi_int', r'C:\Temp\ndvi_float', 4)
"""
try:
import arcpy.sa as sa
# check out license
arcpy.CheckOutExtension('Spatial')
fl_rast = sa.Float(arcpy.Raster(raster) / float(10**int(decimals)))
try:
fl_rast.save(out_raster)
except:
# having random issues with Esri GRID format, change to tiff
# if grid file is created
if not arcpy.Exists(out_raster):
out_raster = out_raster.split('.')[0] + '.tif'
fl_rast.save(out_raster)
try:
arcpy.CalculateStatistics_management(out_raster)
arcpy.BuildPyramids_management(out_raster)
except:
pass
msg('Created: %s' %out_raster)
arcpy.CheckInExtension('Spatial')
return out_raster
except ImportError:
return 'Module arcpy.sa not found.'
示例6: fill_no_data
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CheckOutExtension [as 别名]
def fill_no_data(in_raster, out_raster, w=5, h=5):
"""Fill "NoData" cells with mean values from focal statistics.
Use a larger neighborhood for raster with large areas of no data cells.
*** Requires spatial analyst extension ***
Required:
in_raster -- input raster
out_raster -- output raster
Optional:
w -- search radius width for focal stats (rectangle)
h -- search radius height for focal stats (rectangle)
Example:
>>> fill_no_data(r'C:\Temp\ndvi', r'C:\Temp\ndvi_filled', 10, 10)
"""
try:
import arcpy.sa as sa
# Make Copy of Raster
_dir, name = os.path.split(arcpy.Describe(in_raster).catalogPath)
temp = os.path.join(_dir, 'rast_copyxxx')
if arcpy.Exists(temp):
arcpy.Delete_management(temp)
arcpy.CopyRaster_management(in_raster, temp)
# Fill NoData
arcpy.CheckOutExtension('Spatial')
filled = sa.Con(sa.IsNull(temp),sa.FocalStatistics(temp,sa.NbrRectangle(w,h),'MEAN'),temp)
filled.save(out_raster)
arcpy.BuildPyramids_management(out_raster)
arcpy.CheckInExtension('Spatial')
# Delete original and replace
if arcpy.Exists(temp):
arcpy.Delete_management(temp)
msg('Filled NoData Cells in: %s' %out_raster)
return out_raster
except ImportError:
return 'Module arcpy.sa not found.'
示例7: meters_to_feet
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import CheckOutExtension [as 别名]
def meters_to_feet(in_dem, out_raster, factor=3.28084):
"""Convert DEM Z units by a factor, default factor converts m -> ft.
*** Requires spatial analyst extension ***
Required:
in_dem -- input dem
out_raster -- new raster with z values as feet
factor -- number by which the input DEM is multiplied,
default is 3.28084 to convert metres to feet.
Example:
>>> meters_to_feet(r'C:\Temp\dem_m', r'C:\Temp\dem_ft')
"""
try:
import arcpy.sa as sa
arcpy.CheckOutExtension('Spatial')
out = sa.Float(sa.Times(arcpy.Raster(in_dem), factor))
try:
out.save(out_raster)
except:
# having random issues with esri GRID format
# will try to create as tiff if it fails
if not arcpy.Exists(out_raster):
out_raster = out_raster.split('.')[0] + '.tif'
out.save(out_raster)
try:
arcpy.CalculateStatistics_management(out_raster)
arcpy.BuildPyramids_management(out_raster)
except:
pass
arcpy.AddMessage('Created: %s' %out_raster)
arcpy.CheckInExtension('Spatial')
return out_raster
except ImportError:
return 'Module arcpy.sa not found'