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
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
48 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
51 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
55 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
32 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
18 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
37 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
32 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
33 views

UpdateCursor: value from different rows (ArcPy) [closed]

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
26 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
51 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 ...
2
votes
2answers
53 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
51 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
51 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
50 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
40 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
31 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
29 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
42 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
30 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
107 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
25 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
1answer
56 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
24 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
28 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
49 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
47 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
26 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. ...
1
vote
1answer
44 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
36 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
21 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
46 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
41 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
16 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
21 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
23 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
24 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
33 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
25 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 ....