本文整理汇总了Python中arcpy.AddFieldDelimiters方法的典型用法代码示例。如果您正苦于以下问题:Python arcpy.AddFieldDelimiters方法的具体用法?Python arcpy.AddFieldDelimiters怎么用?Python arcpy.AddFieldDelimiters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arcpy
的用法示例。
在下文中一共展示了arcpy.AddFieldDelimiters方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_percent_access_polys
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddFieldDelimiters [as 别名]
def create_percent_access_polys(raw_cell_counts, percents, out_fc, fields_to_preserve, scratch_workspace):
'''For each percent threshold, dissolve the cells where the number of times reached exceeds the threshold. Each
threshold gets its own polygon, and they are all output to the same feature class.
Params:
raw_cell_counts: Feature class of cell-like polygons with counts generated from create_raw_cell_counts_fc()
count_field: The field in raw_cell_counts containing the number of times the cell was reached
percents: List of percents to calculate results for. Example: 80 means crate a polygon representing the area that
could be reached for at least 80% of start times.
num_time_steps: The total number of time steps present in the input time lapse polygon dataset
out_fc: Path of the output feature class for storing the percent access polygons
'''
first = True
temp_out_dissolve_fc = os.path.join(scratch_workspace, "Temp_" + guid + "_Dissolve")
for percent in sorted(percents):
# Select all the cells where the number of times with access is >= our percent threshold
# The result is all the cells that are reachable at least X% of start times
query = arcpy.AddFieldDelimiters(raw_cell_counts, "Percent") + " >= " + str(percent)
percent_layer = arcpy.management.MakeFeatureLayer(raw_cell_counts, "PercentLayer", query).getOutput(0)
# Dissolve everything that meets the threshold into one polygon
if first:
out_Dissolve = out_fc
else:
out_Dissolve = temp_out_dissolve_fc
arcpy.management.Dissolve(percent_layer, out_Dissolve, fields_to_preserve)
percent_field = "Percent"
arcpy.management.AddField(out_Dissolve, percent_field, "DOUBLE")
arcpy.management.CalculateField(out_Dissolve, percent_field, str(percent))
if not first:
# If this wasn't the first percent output, append it to the master output fc
arcpy.management.Append(out_Dissolve, out_fc, "TEST")
first = False
# Clean up temporary output
if arcpy.Exists(temp_out_dissolve_fc):
arcpy.management.Delete(temp_out_dissolve_fc)
示例2: maskCoastlineConflicts
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddFieldDelimiters [as 别名]
def maskCoastlineConflicts(prod_db, desktop_fldr):
arcpy.AddMessage("\tMasking coastline and bridges")
# Subtype field used in where clause to access bridges in CulturalFeaturesA
subtype_fld = arcpy.AddFieldDelimiters(prod_db, "FCSubtype")
# Get subtype of Bridge
bridge = "5"
# Define spatial reference
sr = arcpy.SpatialReference(4326)
# Get CoastlineL and CulturalFeaturesA layers
coastlinel_fc = getFC(prod_db, "CoastlineL", NAUT_FDS)
culturalfeaturesa_fc = getFC(prod_db, "CulturalFeaturesA", NAUT_FDS)
# Only continue if CoastlineL and CulturalFeaturesA layers are in the TOC
if coastlinel_fc != "" and culturalfeaturesa_fc != "":
# Make feature layer form CoastlineL
arcpy.MakeFeatureLayer_management(coastlinel_fc, "coastlinel_lyr")
# Make feature layer of bridge features
where = subtype_fld + " = " + bridge
arcpy.MakeFeatureLayer_management(culturalfeaturesa_fc, "bridges", where)
# Check if there are any bridge features in the layer
if int(arcpy.GetCount_management("bridges").getOutput(0)) > 0:
# Run Intersecting Layers Mask GP tool to create mask poly where coastline intersect bridges
mask_fc = os.path.join(prod_db, CARTO_FDS, "MASK_CoastlineL")
arcpy.IntersectingLayersMasks_cartography("bridges", "coastlinel_lyr", mask_fc, REF_SCALE, sr, "0.01 POINTS")
return
示例3: testcreate_pie_chart
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddFieldDelimiters [as 别名]
def testcreate_pie_chart(self):
tab = fc = os.path.join(self.testing_gdb, 'Illinois_county_info')
oid = arcpy.AddFieldDelimiters(tab, arcpy.Describe(tab).OIDFieldName)
where = '{0} < 11'.format(oid)
tv = arcpy.MakeTableView_management(tab, 'IL_table', where)
fig = os.path.join(self.testingfolder, 'IL_county_pop.png')
# will use 'CNTY_FIPS' as case field since our pop field is
# already populated for each county
ap.create_pie_chart(fig, tv, 'NAME','POP2000', 'IL Counties')
self.assertTrue(os.path.exists(fig))
#### try:
#### arcpy.Delete_management(fig) # may want to look at the figure, pretty cool!
#### except:
#### pass
pass
示例4: cartoLimits
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import AddFieldDelimiters [as 别名]
def cartoLimits(aoi, prod_db, desktop_fldr):
# Subtype field used in where clause to filter inputs to Model
subtype_fld = arcpy.AddFieldDelimiters(prod_db, "FCSubtype")
# Make feature layer of aoi
arcpy.MakeFeatureLayer_management(aoi, "aoi")
# Convert AOI to polyline
aoi_line = os.path.join(arcpy.env.scratchGDB, "aoi_line")
arcpy.FeatureToLine_management("aoi", aoi_line)
arcpy.MakeFeatureLayer_management(aoi_line, "aoi_line")
# Get list of input feature classes, subtypes, and cart limit feature classes
inputs = [["DangersA", [], "DangersA_L"],
["DepthsA", ["5", "10", "15"], "DepthsA_L"],
["IceFeaturesA", [], "IceA_L"],
["MilitaryFeaturesA", [], "MilitaryA_L"],
["NaturalFeaturesA", ["1", "20", "35"], "NaturalA_L"],
["OffshoreInstallationsA", [], "OffshoreA_L"],
["PortsAndServicesA", ["5", "10", "25", "30", "35", "40", "45", "50", "55", "60", "65", "70", "80"], "PortsA_L"],
["RegulatedAreasAndLimitsA", ["1", "5", "10", "15", "20", "30", "40", "50", "60", "65", "70", "75", "85", "95", "105", "110", "115"], "RegulatedA_L"],
["SeabedA", ["15"], "SeabedA_L"],
["TracksAndRoutesA", ["1", "5", "10", "15", "20", "25", "40", "45", "70"], "TracksA_L"]]
# Set workspace
arcpy.env.workspace = prod_db
# Get CoastlineA and CloastlineL layers
coastlinea_fc = getFC(prod_db, "CoastlineA", NAUT_FDS)
arcpy.MakeFeatureLayer_management(coastlinea_fc, "CoastlineA")
coastlinel_fc = getFC(prod_db, "CoastlineL", NAUT_FDS)
arcpy.MakeFeatureLayer_management(coastlinel_fc, "CoastlineL")
# Loop through list of inputs
for data in inputs:
# Get full paths to data
input_fc = getFC(prod_db, data[0], NAUT_FDS)
output_fc = getFC(prod_db, data[2], CARTO_FDS)
if input_fc != "" and output_fc != "":
# Check if there are subtypes, if there are, write where clause
where = ""
if len(data[1]) > 0:
where = subtype_fld + " = "
where = where + (" OR " + subtype_fld + " = ").join(data[1])
# Remove single quotes that get added to beginning and end of where clause
where = where.replace("'", "")
# Select features in where clause
arcpy.MakeFeatureLayer_management(input_fc, "in_lyr", where)
# Only run Generate Cartographic Limits model if layer has features
if int(arcpy.GetCount_management("in_lyr").getOutput(0)) > 0:
arcpy.AddMessage("\t\t" + data[2])
arcpy.GenerateCartographicLimits_nautical("in_lyr", "CoastlineL; CoastlineA; aoi_line", output_fc)
return