Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [arcpy]

A site-package created by Esri to expose ArcGIS Desktop (ArcMap and ArcGIS Pro) geoprocessing, mapping, etc, to Python.

0
votes
1answer
37 views

Selecting points in polygon in a range of time (ArcGIS)

I have: - point GPS for people (time in seconds) - buffer GPS for a car (time in seconds) What I want to do is for each buffer GPS coordinate, I want to find the number of GPS people points inside ...
0
votes
1answer
35 views

Using an SQL Query to skip or run a code in ArcPy/ Python

Using ArcMap 10.4 and Python I am trying to run a code (arcpy.ExportReport) on a bunch of different frequency tables. Which I have completed the only problem is that if I have a table that does not ...
0
votes
0answers
37 views

Implementing if-then-else logic for number of points or area greater than x

I wish to alter this script (see below) that I use in model builder to choose which analysis to run next. I want to make "is state plane" process to run if "number of points (shapefile) is equal to or ...
1
vote
1answer
43 views

Projecting shapefile of point geometries?

I am trying to creating a point shapefile that lies within polygon(a feature layer). By creating point geometry objects and filtering the ones that fall within the polygon(feature layer), I created a ...
0
votes
1answer
37 views

Converting from Boolean to point features using ArcPy?

I used geometry objects and da.searchCursor to check if randomly created points fall within polygon. Now I get True and False of each points that falls within or outside of the polygon. I made a list ...
0
votes
1answer
24 views

Geoprocessing server tool result has no internal record set object for Save

I'm working with the geoprocessing server tool (GenerateOriginDestinationCostMatrix) imported as a toolbox (OriginDestinationCostMatrix) in ArcMap 10.6. Being asynchronous I use the resultID with ...
0
votes
1answer
59 views

Updating attribute table of base shapefile from .csv file?

I am new to python programming. I am trying to create a script that can update attributes in a base shapefile based on a .csv file when changes are made to the .csv file. I also want the script to ...
1
vote
3answers
75 views

Searching for NULL values in feature class table

I am looking for a way which I can search whole my feature class in ArcMap to find if has any NULL values on it. I know how can I do this with "Select By Attribute", but I am looking for a faster way ...
0
votes
1answer
23 views

Adjusting multiple text elements in multiple mxd files?

I am trying to make changes to titles on multiple mxds instead of having to open 1 by 1 but it is only making changes to 1 mxd file, I have even tried to make duplicate copies of the mxd to test but ...
0
votes
1answer
37 views

Updating/modifying Network Dataset roads source in Enterprise Geodatabase (ArcSDE) using ArcPy?

I am trying to create a Python script that automate the update of roads source used in a network dataset stored in a Enterprise Geodatabase (SDE). In short, I want to truncate the roads feature class ...
1
vote
3answers
90 views

Linearly comparing one point to all points within 20' foot area, for every point in dataset using ArcPy?

I have a very large dataset of GPS point that I am trying to write a python script for that will linearly compare one points to the ones around it. Original I was using the ID to determine which point ...
0
votes
1answer
29 views

Populate field with result from a function?

I want to make a new column in every shapefile using for loop and populate that column using a function. #the function def find_folder(fn, k=-2): return os.path.split(fn)[0].split(os.sep)[k] I ...
1
vote
2answers
44 views

Adding shapefile to multiple MXDs using ArcPy?

My ArcMap verison is 10.6. The purpose is to add a wetland shapefile to multiple MXDs. It doesn't work and the error said the addLayer is not defined. My script is below. Does anyone have an idea? ...
1
vote
1answer
32 views

Printing name of each layer in mxd using ArcPy?

My ArcMap verison is 10.2. My goal is to print the name of each layer in a mxd using Arcpy. My script is below. There is no error, but it prints the first layer multiple times instead of all the ...
0
votes
1answer
35 views

ArcMap “Polyline to Raster” output is empty greyscale raster

I have a polyline shapefile of streams that I am attempting to convert to a raster using the "Polyline to Raster" conversion tool. However, rather than outputting a raster with distinct stream pixels, ...
1
vote
1answer
38 views

Merging on specific fields

Lets say I have three shapefiles/features I want to merge: 'florida.shp', 'mississipi.shp' and 'louisiana.shp'. They all have 3 standard fields common to all: 'DFIRMID', 'SFX', and 'FIRMPAN'. I want ...
1
vote
2answers
35 views

Altering text elements in multiple mxds?

I am trying to make changes to titles on multiple mxds instead of having to open 1 by 1 but keep getting an error. import arcpy.mapping as mapping, os for root, dirs, files in os.walk(r"F:\Final ...
1
vote
1answer
14 views

Text element name not appearing in ListLayoutElements

As in the title, I have the simple below code: import arcpy arcpy.env.workspace = r"U:" mxd = arcpy.mapping.MapDocument(r"U:RAFT.mxd") layoutlist = arcpy.mapping.ListLayoutElements(mxd, "...
0
votes
1answer
64 views

Buffering a line

I would like to construct a feature class consisting of every polygon in the landuse shapefile entirely within a 300 Feet buffer of the Road. But I always get error of C:\Road300 does not exist or not ...
1
vote
1answer
65 views

arcpy.da.searchCursor - need to go through all records, but only go through one. What am I missing?

My script supposed to go through all rows in one dataset, fl1: select one row at a time, based on that selection, select spatially from another dataset, fl2 if spatially identical records were found,...
0
votes
3answers
46 views

Making one field/values equal to another field/values

Lets say I have created a new field called "SFX" in a shapefile called "myshape.shp": input = r"C:\files\myshape.shp" arcpy.AddField_management(input, "SFX", "TEXT", field_length=100) There is now ...
0
votes
1answer
29 views

Capturing specific error instead of arcpy.ExecutionError?

How can I specify this script to capture specifically the error 001566, instead of the current general execution error? Error 001566:Failed to create raster dataset. The reason could be: The ...
0
votes
0answers
35 views

Adding field to middle of attribute table using ArcPy? [duplicate]

When executing the add field command in arcpy it always appends the field at the end of an attribute table. Can someone help me write a code where a field can be inserted in the middle of an ...
0
votes
1answer
38 views

Batch Dissolving FC into New FCs based on Field Name using ArcPy?

I am trying to take a FC, export individual FCs based on fields in the original FC, and have the new FCs dissolved. I found a Python script that works and modified it for my use - see below. # ...
0
votes
2answers
55 views

Automating Select by location using ArcPy and where_clause?

I have used the code in Coding python loop to select features of polygon layer than are completely contained in group of 11 layers using ArcPy? to automate select by location analysis using ArcPy. I ...
0
votes
1answer
25 views

Adding Greek letters in existing columns in ArcPy?

Example table: colA colB colC 173743 01 8974 173443 02 8934 173943 05 8924 173243 01 8994 173343 03 8964 I want to pass to the third column: The 3 first numbers from the ...
0
votes
0answers
60 views

Failing to read shapefiles in folder using ArcPy?

I want to use create random point tool on list of shapefiles, but keep failing to list the shape files. My code stops at line (print fcList); and gives me "None" as output. Is it because of the ...
1
vote
1answer
72 views

Looping Eliminate tool in Python?

I am very new at Python,I'm not sure if this is even the appropriate way to do what I want to do, but basically, I'm looking to eliminate all of the small polygons in a feature class that was created ...
0
votes
2answers
55 views

1000 features limit using CopyFeatures_management?

I wrote a script to select features from a sql server spatial database based on date, there are thousands and thousands of records. The script runs but when I used the CopyFeatures_management tool, ...
1
vote
0answers
16 views

Get x coordinates in a new field in ArcPy? [duplicate]

In desktop you can do that by: calculate geometry and then select X_Coordinate_of_centroid. How to do this in ArcPy? Tried: arcpy.AddField_management("f1.shp","X_Coord","DOUBLE") arcpy....
-2
votes
1answer
60 views

Stratified random point sampling in Python

I have a very basic knowledge in Python and arcpy. I want to create a stratified random sampling point on a continuous polygon. So far, I have dissolved the polygon (according to categories) and ...
0
votes
1answer
41 views

Calculating the length

Can someone break this script in to a few lines so that I know what I am doing? I understand the code about finding the length of a Polyline, but how to break this into step by step? Here is the ...
2
votes
0answers
47 views

Using Reclass in Arcpy, Error 010005: Unable to Allocate Memory

I've derived a raster of slopes from a 10 m DEM resampled to 15 m for an area of approximately 20,000 mi^2. I want to use Python to reclassify those slopes into categories according to range, but ...
0
votes
1answer
48 views

arcpy SelectLayerByAttribute_management runs in the Python window in ArcGIS Pro, but fails to run from Spyder or PyCharm

I have this script for querying a feature layer and then copying to a geodatabase. It works when I run it in the ArcGIS Pro Python window, but not when I run it from Spyder or PyCharm. When I run in ...
0
votes
1answer
38 views

Run model from script

This is my script where I am trying to use selectby_attribute within a model, based on a field, F*. There are 6 fields, so I want 6 derived layers. Then I am going to use bearing and distance tool ...
0
votes
1answer
92 views

Using Update Cursor gives IndexError: list assignment index out of range?

I am trying to use an update cursor and receiving an error. I'm not very familiar with using cursors, so please bear with me. I am trying to write a 1 or 0 to a field, based on a condition. The error ...
0
votes
1answer
48 views

Using arcpy.mp to export map to JPEG?

I am using ArcGIS Pro for my map automation. I try to use arcpy.mp module to identify the maps in the current project. I want to export the map into a jpeg image like what we can do via Map Export ...
0
votes
0answers
25 views

Change datasource of layer file object (outside of mxd) to source on SDE

I am creating a number of layer object files outside of an MXD document (the layer is being copied from a separate layer object file outside of an MXD) and attempting to loop through each new lyr ...
0
votes
2answers
42 views

ArcPy if part of string not in field, then delete row

I am able to use UpdateCursor to find and delete rows if a field contains part of a string (code below works). Now I want to do the opposite--if part of this string is not in my field, I want to ...
1
vote
1answer
18 views

Saving a Child Object as a Feature Class/Layer

I'm very new to arcpy, my terminology might not be the most precise/accurate. I'm having trouble saving a sublayer (named "LALines") from a Location Allocation Solve Result as a feature class. As I ...
2
votes
1answer
42 views

Copying feature classes from gdb to different folder locations in Python?

I am very new to Python, and I'm trying to create a function where I'm copying over feature classes from a gdb to different folder locations as shapefiles. The script needs to be reading from a ...
4
votes
3answers
90 views

Automatically assigning attribute to line features

I have a network of railway switches and I need to assign the value of a switch line being left or right automatically. What do I have: A feature class containing a track that looks like this I need ...
0
votes
2answers
31 views

How to break a string line with many values to a single field?

I don't speak English very well... I have this case, for FID in field "CPFS*" exists some codes. I need in field "identifica" only one. For exemple: to [FID = 0 identifica = 00417549210], to [FID = 1 ...
0
votes
1answer
21 views

IndexError when adding multiple fields to shapefile

As part of a larger project i'm looking to add multiple fields to a shapefile using an index. This is the snippet in question: listFields = [['ITEM', 'TEXT'], ['SYSTEM', 'TEXT'], ['WATERCOURCE_BANK', ...
1
vote
2answers
36 views

Merge Featureclasses if there is more than one in the FeatureClassSet

i want to check through all my gdb if a FeatureClassSet contains more than one FeatureClass. If so merge them and save the result in an other gdb otherwise just copy them to the gdb. It sounds really ...
2
votes
1answer
21 views

Ranking occurrences in field using ArcPy?

I have a field C_CODE and I would like to count occurences of values in that field that will start with zero in front of the one digit numbers:Ex: 01,02 and normally for two digit numbers Ex:..09,10,...
2
votes
0answers
41 views

Python script to zoom to a city and export as PDF won't zoom to city [closed]

The script completes successfully but doesn't zoom to the given city. It does export to PDF with the correct name though. The map is the county wide extent and not zoomed to the given city. The print ...
0
votes
0answers
19 views

How to convert WGS84 coordinates to screen pixel coordinates? [duplicate]

I have a set of points that are defined as WGS84. In ArcMap the featureclass details are: Geographic Coordinate System: GCS_WGS_1984. Datum: D_WGS_1984 Prime Meridian: Greenwich Angular Unit: Degree. ...
0
votes
0answers
49 views

Moving Feature Class to Different Feature Dataset within Same File Geodatabase using ArcPy?

I want to progammatically move a feature class into a different feature dataset within the same file geodatabase. I'm wondering if there is a way of doing this without including code to rename and ...
0
votes
0answers
28 views

Classification using arcpy 2.7

I'm trying to create a tool that will consume National Weather Service 1 hour precipitation radar information and then classify groundcover based on amounts per area (in mm), then output the results ...