Questions tagged [arcpy]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
21 views

00068 Script Script contains broken project data source: CURRENT

Can't share my script as geoprocesing service. The warning message: 00068 Script Script contains broken project data source: CURRENT Here is the script: # Import arcpy module import arcpy arcpy.env....
-1
votes
2answers
26 views

Attempting to use cursor to filter results by date, then use groups of records to find max value

In my data, I have a table view where I am trying to group same records (PID), then filter records by date (ROW_CREATE_DATE). if the record has the date of 2019-03-05 then find records in the line # ...
0
votes
1answer
44 views

Python- Make use table from a MDB with name changes every week (name+date)

I have been trying to make a script to automate some steps in a process that uses tables from different databases. One of them changes its name every week - name+date eg: "MegaDataBase_16062019.mdb" ...
2
votes
1answer
168 views

Returning strings showing all vertices from all polygons in shapefile using ArcPy?

I want to have a string showing all vertices from all polygons in a shapefile. In my example below my code lists all vertices and the first column shows the polygon they are part of (I only have 2 in ...
0
votes
0answers
38 views

Adding Polygon to shapefile of particular area from Excel?

I have Excel data in which polygon number is given, in correspondence to that there is particular Area given. I have 5000 to these entries. Now in the shape file, we have to edit every polygon and add ...
1
vote
1answer
34 views

Boolean precondition in ModelBuilder not exporting to Python script

I don't know python so I often use ModelBuilder and export to python script. In this case, I have a model (that in itself is made of python scripts that have been exported from models) that works fine ...
0
votes
2answers
45 views

Adding ArcGIS Server feature service to ArcMap data frame using Python? [closed]

There's an external ArcGIS Server that I've been manually going into through ArcCatalog to pull down feature services and save them off as feature classes. I do this twice a month, so I would like to ...
2
votes
1answer
41 views

arcpy.da.NumPyArrayToTable() RuntimeError: Unspecified error

Using arcpy for ArcGIS Desktop 10.7.1... In order to append data from a Pandas data frame to an ArcGIS table, I am attempting to create a temporary in-memory table from the Pandas data frame as ...
2
votes
1answer
135 views

Using ArcPy to insert new data into shapefile without editing it?

I want to insert new data into a empty shapefile. I have an array with the fields values of each row and I use InsertCursor to add these data to my shapefile. When I run the code if the shapefile is ...
1
vote
2answers
50 views

Understanding and using fieldmapping with ArcPy?

I'm having trouble trying to understand how fieldmapping works in ArcPy (I'm kinda new to Python). In the below example, I want to take a shapefile and append it to a feature class. But I want to use ...
1
vote
1answer
57 views

Comparing a polygon layer within the boundary of a polygon

I'm pretty new to ArcPy and Python. In our database, we have a layer containing parcels (polygons) with a neighborhood code and a polygon layer that contains the neighborhood boundary. Within that ...
2
votes
0answers
29 views

ArcPy name raster layer

I am using ArcPy to save a TIFF file in a geodatabase file with this code: arcpy.RasterToGeodatabase_conversion(Input_Rasters=r'D:\Projects\GEBCO_2019_Geotiff.tif', Output_Geodatabase=r'D:\Projects\...
1
vote
1answer
19 views

Adding multiple feature classes (everything within gdb) to a group layer in ArcGIS Pro - Python

I am currently trying to add all the feature classes contained within a gdb to a group layer in ArcGIS Pro via a script. I have however not managed to add more than one single feature class at a time. ...
3
votes
1answer
44 views

Insert Cursor Not Filling XY Field

I have a table with a set of original XY values and a set of new XY values. I want to create new points of the new xy's using the insert cursor. My code updates the ID and Sp row but not the XY row. ...
-3
votes
1answer
54 views

Excluding certain Tables and Table Columns out of Analysis using ArcPy? [closed]

My code currently follows this format: Create FGDB From local folder, get list of all tables Do TableToGeodatabase_conversion on all tables What I want to do now is exclude certain tables from being ...
1
vote
1answer
23 views

Setting default value for date columns with FeatureClassToNumPyArray in ArcGIS Pro?

I am reading a feature class into a pandas dataframe using: df = DataFrame( arcpy.da.FeatureClassToNumPyArray( in_table=feature_class, field_names=field_list, skip_nulls=...
0
votes
0answers
25 views

Undoing Operation while editing in ArcMap with Python Add-ins?

Using ArcPy Add-ins, I can issue a message, but I don’t understand how to cancel or undo deleting an object. Is it possible? class ControlUniq(object): """Implementation for addin1_addin....
0
votes
1answer
36 views

Getting Con statement in ArcPy to work?

I have a script in Python that includes a series of Spatial Analyst tools. I need to reclassify a raster and have tried using Remap which fails and have also tried a Con statement. The Con statement ...
1
vote
2answers
36 views

Use ArcPy for finding value throughout all fields and export to new layer

I need to find a way to find a specific value in the attribute table and then export all rows with said value to a new feature class. Below is the code that I have managed to come up with (using ...
2
votes
0answers
29 views

Identifying raster max and converting to point using ArcPy?

This is a variant of finding max elevations in a raster and converting them to point containing the max value. I have done this successfully using the full raster (39000x39000), zonal stats, and a CON ...
0
votes
1answer
53 views

Using ArcPy in Python class

I am trying to create a tool that creates dimension lines but I am getting error. Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "<...
0
votes
0answers
22 views

RuntimeError: Objects in this class cannot be updated outside an edit session

I recieved this error: RuntimeError: Objects in this class cannot be updated outside an edit session while runnng this code: # import modules import arcpy import random from arcpy import env ...
0
votes
1answer
33 views

Arcpy SDE Connection Getting Invalid Path? [closed]

I literally copied and pasted the file path (r'C:\Users\myName\AppData\Roaming\ESRI\Desktop10.4\ArcCatalog\mydatabase.sde'), but after I run my script, I always get the error saying error 267, the ...
0
votes
0answers
25 views

Checking if feature class is table in FGDB using ArcPy?

I basically want to do something like: if my_fgdb has data type "tables" then do this A similar function I know of is something like .startswith("xx"), so something similar to that like .typeis("...
0
votes
0answers
19 views

Delivering script tool using toolbar vs addin button?

I am having trouble determining how to best deliver my script tool for use in ArcMap 10.7. I can create a toolbar that has my custom script tool in it. That is easy. The trouble is I can't get the ...
1
vote
0answers
25 views

Raster calculator giving different results in ArcPy than in ArcGIS?

I have two rasters representing travelling speed: one for road (with speed values for different types of roads and "0" values where there is no roads) and one for land-cover (with lower values, but no ...
0
votes
0answers
29 views

Don't allow to save edits in the table untill the field will be populated in ArcGIS with pythonaddins

I have a table and some fields there(OBJECTID, UN_ID, for example).Table is not empty. how to prevent an edit session from stopping or saving until the field will be filled. I wrote an extension ...
0
votes
0answers
28 views

Iterating through values in Attribute field and performing selection using ArcPy?

I am using ArcGis Pro 2.4 python window. I have seen suggestions of using "SearchCursor" but am unclear how to utilize this tool in the Where-Clause in my SQL selection statement to select by ...
0
votes
0answers
26 views

How can I create a layer for each unique field item in a shapefile using Arcpy

#Introduction and imports import arcpy, string from arcpy import env #User Inputs: layer, field name, output workspace (optional) strTargetLayer = arcpy.GetParameterAsText(0) strFieldName = arcpy....
1
vote
1answer
32 views

Iterating through 2 different Geodatabases at same time using ArcPy?

I have 2 gdb's; one that contains a polygon feature class of census blocks(cb), and one that contains centroids that may lie within those census blocks. They are organized by state. Ex: FL_cb = ...
0
votes
1answer
34 views

Checking to see if database is there and delete if so using ArcPy?

I am looking for my python code to check for the polycheck.gdb and if it is there delete and create a new one. Also, I would like to set my workspace to that database. Not sure if this is the right ...
2
votes
1answer
25 views

Find gaps in spatial database based on attributes and fill those caps with new features with existing attributes

I have a big line shapefile data (over 2 millions features) showing animal movements. Simplified example: ID    Year    st_time     end_time&...
0
votes
0answers
13 views

Arcpy exporting feature by attribute in ArcMap 10.3 [duplicate]

I'd like to automate exporting each polygon feature by attribute(year) in a shapefile to seperate shapefiles named by year Now I know this exists in arcpy with 10.5 or higher using the ...
1
vote
2answers
46 views

Transferring Data From One Table to Another Using Multiple Keys in ArcPy?

I have data in one field and I want to transfer it to a specific field in another table based on specific keys Such as ID, road_type and veg_type. My original table looks like this ID Road_Type ...
5
votes
1answer
47 views

Error in reclassifying with ArcPy

I am trying to reclassify DEM using arcpy.sa.Reclassify and it is showing an error. Following are my commands: dem_re=arcpy.sa.Reclassify("dem_extfish.tif","VALUE",arcpy.sa.RemapRange([[391, 677, 1],...
0
votes
2answers
49 views

Passing string field value to another field in same Feature Class using ArcPy?

All the literature I have read suggests that to pass a string value to a another field in a feature class via ArcPy you need to do the following. I am running it in ArcMap 10.6. arcpy....
0
votes
1answer
50 views

arcpy script to set TIFF color

I have a Python script that read csv files containing location and attributes for several objects and put all of them in a geodatabase. I modified this script adding also a TIFF imagine with the ...
3
votes
2answers
47 views

Inserting field values in table?

I am trying to insert Field Values to an empty table. My code by so far: arcpy.CreateTable_management(r"C:\Users\esri\Documents\ArcGIS","test") arcpy.AddField_management("test","total","LONG") arcpy....
1
vote
1answer
53 views

Combining PDFs in Folder using ArcPy for ArcGIS Pro?

This was able to combine two pdfs in a folder into one pdf, but unable to combine more than this. import arcpy, os # Set the workspace. arcpy.env.workspace = r"C:\Output" #Set file name and remove ...
1
vote
1answer
53 views

Summing Values for Each Item in a Dictionary

# Create dictionary with segmentid as key, calculated length as value1, measured length as value2 fiberCableLengths = defaultdict(list) with arcpy.da.SearchCursor(fiberCable, ['segmentid', '...
2
votes
1answer
36 views

Changing part of text with ArcPy?

I try to replace part of text in 23 mxd files from "d" into 'map num: '. The code run without errors, but the result in the maps is only the character "m" instead of 'map num: ' I run this code: ...
1
vote
1answer
48 views

Definition query not updating [closed]

I have an ArcMap 10.3 MXD in which which I am trying to update the definition query of an enterprise geodatabase layer using Python: import arcpy, os, re from arcpy import env inmxd = r'C:\Temp\...
0
votes
1answer
30 views

Getting error while creating createMapSDDraft using Python

I am getting error while creating the MapSDDraft using Python. import arcpy import os import xml.dom.minidom as DOM workspace = r'C:\\Users\\xyz\\Documents\\ArcGIS\\' mxd = 'TEST.mxd' con = r'C:\\...
1
vote
1answer
38 views

Select by Attribute error - ArcPy [duplicate]

I have a table of points that looks something like this: year, latitude, longitude 2018, 42.02, -87.68 2018, 41.91, -87.78 2018, 41.64, -87.68 2017, 41.63, -87.56 2017, 41.89, ...
1
vote
0answers
33 views

Importing/downloading symbology from ArcGIS Online using ArcPy?

I am currently attempting to create a script to download shapefiles from ArcGIS Online to my local drive before adding it to an aprx project and thereafter uploading it to a ArcGIS portal/enterprise. ...
1
vote
1answer
17 views

Project with multiple MapSeries - script to select specific series and range

Currently working a project that contains 9 map series with over 22,000 pages total - split across datum and scale. Want to script a solution that allows us to export pages as individual PDFs by ...
0
votes
1answer
41 views

Trying to print 10 separate PDFs using ArcPy but overwriting same PDF file?

I am using ArcPy with ArcMap 10.5. I have a written a script that reads an Excel file, plots the X,Y points, creates heatmap rasters, and prints them to PDF. The broken part is that the PDF is ...
0
votes
1answer
32 views

List index out of range when converting layers as a service definietion

In ArcGIS Pro python window: I'm adding certain layers into a list. From that list, I am converting the list in a service definition draft. I use this same script all the time, sometimes I'll get ...
0
votes
0answers
23 views

Fieldmapping for mean and max using arcpy

I'm trying to spatial join two features. One polygon layer and one point layer. The point layer contains one field of values that I want the Mean and Min of. Im trying to use the fieldmaper object to ...
0
votes
1answer
29 views

Adding multiple feature classes (gdb) to map file (aprx) by using addDatafromPath in ArcPy?

I have some problems adding multiple feature classes (not only a single one) from a geodatabase to a map file in an ArcGIS Pro project and I'm wondering if someone knows of a solution to this. To be ...