Python arcpy.AddFieldDelimiters() Examples
The following are 4
code examples of arcpy.AddFieldDelimiters().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
arcpy
, or try the search function
.
Example #1
Source File: CreatePercentAccessPolygon.py From public-transit-tools with Apache License 2.0 | 5 votes |
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)
Example #2
Source File: s57_2_chart.py From maritime-charting-sample-scripts with Apache License 2.0 | 5 votes |
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
Example #3
Source File: arcapi_test.py From arcapi with GNU Lesser General Public License v3.0 | 5 votes |
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
Example #4
Source File: s57_2_chart.py From maritime-charting-sample-scripts with Apache License 2.0 | 4 votes |
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