Questions tagged [arcpy]

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

1
vote
1answer
36 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 ...
0
votes
0answers
14 views

Install PyQt5 on Python 2.7

I have an ArcPy standalone script that uses PyQt5 for the interface: # -*- coding: utf-8 -*- # Import arcpy module from __future__ import print_function import datetime import arcpy import os import ...
0
votes
1answer
25 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', '...
0
votes
0answers
10 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
0answers
32 views

Definition query not updating

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
0answers
25 views

Assigning values to points based on near polygons using ArcMap? [on hold]

I have two vector files. One with points and the other one with polygons with data of interest (from 1 to 5 as discrete data). I want to assign to the points the same discrete data based on the ...
0
votes
0answers
7 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
35 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
26 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
12 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
35 views

How to fix ArcPy script that should print 10 separate PDFs but is overwriting the same PDF file (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 overwriting itself rather than producing ...
0
votes
1answer
21 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
18 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
22 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 ...
1
vote
1answer
27 views

UpdateCursor: value from different rows (ArcPy) [on hold]

I am new to ArcPy. I have an attribute table with the following columns and fields I want to fill up the column Combined as follows: If number contains 2 categories, "combined" will be A,B. If ...
1
vote
1answer
24 views

Performing DTM compression using ArcPy?

I have a set of 32-bit TIFF files of DTM data (50 sm) and I need to save them as 16-bit. In order to save some space, I compressed them using LZW algorith and saved as 16 bit tiffs using Arcpy. But ...
0
votes
1answer
32 views

How to get the “modified” date for a FeatureClass in a file geodatabase via ArcPy?

There is a closed question which is similar to or identical to this question: Getting date modified for a feature class within a file geodatabase via arcpy Looking at a file geodatabase featureclass ...
1
vote
2answers
42 views

Update 1 random value in a group of values

I have an attribute table with a date field and a random field. The date field has three different times for each day. I need to input a '1' in the random field for one of those three times in each ...
0
votes
1answer
50 views

How to fix this Heatmap script from failing SQL expression (integer/string?) using arcpy (ArcMap 10.5)?

I have a heatmap script that will eventually print 10 PDF maps. At the moment it is failing at the SQL expression in the Make Feature Layer right before Kernel Density Raster creation because the ...
1
vote
0answers
47 views

Datetime on attribute tables

I have written a script to add, among other stuff, a datetime column. I have used the arcpy.AddField_managementcommand, but it didn't have a 'Datetime' type, so I used the 'Date' type : arcpy....
0
votes
2answers
42 views

Automating Excel to Table in larger script in ArcMap using Python?

This is the first part of a larger script i'm working on to automate heatmaps. Currently I'm receiving this error with ArcMap 10.5: Traceback (most recent call last): File "\coacd.org\dfs\SWS\...
0
votes
1answer
39 views

Multiplying points to another feature table using ArcPy?

I have a point feature class like this: And another table looks like this: How can I add point's xy coordinate to that table based on their No. and automatic multiply as their No. multiplies using ...
0
votes
1answer
29 views

Simplifying a long if condition statement and adding status report?

def Assign(csdname, cdname, ccsname, zone): if csdname == "Oshawa" or csdname == "Whitby": return "70" elif csdname == "Toronto": return "71a" elif csdname == "Mississauga" or csdname == "...
1
vote
0answers
26 views

Copy_raster to remove no data value using ArcPy

I have multiple raster, I am trying to remove Nodata value using Copy_raster option. Since I have multiple raster, I am running a ArcPy script, save the raster as same input name. But that script, ...
1
vote
2answers
39 views

Merging feature class with field mappings using datum transformation?

I suspect that there is no easier way to do this, other than developing this as a two-step process with a temporary output (which seems somewhat wasteful). If I have to, I'll just create a temporary ...
0
votes
1answer
25 views

How to update attribute of selected features in ArcMap with a shortcut?

I have to edit/move/create/delete a no of polygons based on their respective comparison with reality. For all the polygons that I've moved, I have to update a field called remark as "U". This is ...
2
votes
1answer
99 views

Using if statement with ArcPy and GetCount?

I am looking to get a count on the polygonNieghbor and if it has polygons in it then I want to move to the next step MakeFeatureLayer. and If it doesn't have any features I would like it to finish. ...
2
votes
1answer
24 views

Dynamically set default file geodatabase to newly created one in for loop with ArcPy

I'm trying to write a script for a tool in ArcGIS Pro 2.x for an annual workflow where I create five time-peroid directories (named 1-5) and then I create both a new file geodatabase and an ArcGIS Pro ...
-1
votes
0answers
44 views

Making looping through line segments for vertex points faster?

I am trying to speed up some current code that I have for looping through lines, getting their segments and ultimately the vertex points in Python. Can anyone recommend a faster method than what I ...
0
votes
0answers
20 views

Updating .aprx file after creating new layer using ArcPy?

I use arcpy function XYTableToPoint_management() to create a new layer vessel_coordinate into the current active map, as shown below. But when I list the layers in this map (map.listLayers()), I hope ...
0
votes
1answer
22 views

arcpy.AddJoin_management() Error [closed]

I'm having an issue with some code I'm trying to write. Here's the code and below that is the output. # -*- coding: utf-8 -*- # -----------------------------------------------------------------...
1
vote
2answers
48 views

Sorting MXDs with specific attributes and exporting to specific directory?

I'm working on creating a GP tool that simply exports all MXDs in an input folder into an output folder as PDFs. This actually works, but I messed something up with output directories. I coded ...
3
votes
1answer
35 views

Applying Definition Query for multiple features using ArcPy?

I'm trying to apply the following code to extract features that contain these letters 'MW' within the field called 'CODE' for multiple layers. But I'm getting a SyntaxError for line 5 (defintion query)...
1
vote
1answer
22 views

Changing map symbology with arcpy?

I've written a program that maps out a specific point file of interest. The program produces a map (clipped map attached below) but I can't figure out how to change the symbology to different colors. ...
0
votes
1answer
31 views

How can I handle ArcMap events of CREATE, UPDATE or DELETE?

As a developer I can use ArcPy (Python) or ArcObjects (.NET) to develop some extensions or tools for ArcGIS platform. But I need to handle some events. When a user connected to an Enterprise ...
1
vote
0answers
35 views

How to copy all files with extension type to a folder? [closed]

What is the best way to go about this? I'm able to do it with a single file as below, but what if I would like to copy all files with .txt to a folder, and all files with .docx to another folder. I ...
0
votes
1answer
19 views

How to use insert extension for more than one value

I am trying to insert 2 values into the 'extensionsofArcGIS' variable as you can see below, just not sure how to insert more than one at a time? I have tried a few different variations but still no ...
0
votes
1answer
23 views

How can I insert degree symbol to attribute table in feature class?

I am trying to insert a bearing string into an attribute table, I want the string to look like this -> S 58°15'31" W , but what I am getting in the table is this -> S 58°15'31" W The code I am ...
0
votes
1answer
36 views

arcpy.da.UpdateCursor not updating [closed]

The script will run without error, but the updatecursor at line 123 does not update the table. the addmessage before and aftr the loop shows right numbers but update does not seem to work. # -*...
1
vote
1answer
23 views

Locating records not in selection using ArcPy?

I have a list of addresses that I need to contact. Some are listed in the attribute table, and some aren't. I'm trying to find the ones that aren't. The list: contacted = ['123 STOWE ST', '123 ROSE ...
0
votes
0answers
13 views

Converting line density layer into classified raster using applied symbology in ArcPy?

Using python in ArcCatalog 10.6 I am trying to apply symbology to a line density layer. I sliced the density map into 9 segments and that is how I want to apply symbology from a predefined layer. It ...
-1
votes
1answer
20 views

Viewing shapefile's attribute table using ArcPy? [closed]

How can I view the attribute table of a shapefile or a raster file as a database using ArcPy?
2
votes
1answer
15 views

Getting error when removing join using Arcpy

I have joined a CSV table to a raster layer, now I am trying to remove the join. I have typed the following command: arcpy.RemoveJoin_management("hwsd_lyr",hwsd_csv) It gives the following error: ...
0
votes
0answers
22 views

What analysis tool I can use to identify the relation between points and areas

I want a binary result for each purple point in this map, i.e. whether in or out od the blue polygon areas? In this case, one is in and the other is out. What analysis tool in ArcGIS Pro (also arcpy ...
1
vote
1answer
32 views

Use Python to find points based on 'month' and 'year' fields

I have a shapefile based on 27 locations, with historical values at each location for each month of the year going back to 1974. The file has 11,000 values. I have been trying to work on a script to ...
3
votes
1answer
23 views

LayerToKML output doesn't render on Google Earth

For the last few weeks I've been making .kmz files using LayerToKML_Conversion with no problem. They open in Google Earth perfectly. Today, they suddenly stopped rendering at all. When I click the ....
0
votes
1answer
20 views

Adding output to ArcPy script in ArcGIS ModelBuilder?

In ArcGIS 10.5, I have the following script which grabs the files from a geodatabase and merges them into one layer: import arcpy # specify the path to the GDB with the asset files #make sure the ...
1
vote
1answer
44 views

To update Point location every 1 second

I am using update cursor to change the location of a point with FID = 0 every second, but whenever I run the code my ArcGIS freezes and point doesnot move. I am visualizing an output where the point ...
1
vote
1answer
23 views

Add date and time to attribute table using ArcPy insertcursor

ArcPy under ArcGIS Pro 2.3.2. I am adding a Python datetime.datetime object to a shapefile attribute table using an arcpy insert cursor. The problem is that when I add the datetime instance, the date ...
0
votes
1answer
21 views

Exporting feature class to geometry objects and preserving attributes - ArcGIS, ArcPy

I'm using ArcPy and would like to copy features in a feature class to geometry objects and then perform a buffer on the geometry objects and copy them back to a feature class. I am doing this in ...