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

Rounding to nearest multiple of pixel resolution using ArcPy

ArcPy can return the pixel resolution: arcpy.GetRasterProperties_management(rasterfile, "CELLSIZEX", "").getOutput(0)) Let's say this returns "3.2808" I wish to be able to take a given input, say "...
0
votes
0answers
9 views

Geocoding 'in_memory' using ArcPy

I need to run a geocode, then do some calculations on the results, and then run the geocode again. Since the first geocode result is intermediate data, I tried to use the in_memory directory to speed ...
2
votes
3answers
1k views

Finding empty attribute field with ArcPy search cursor?

I'm trying to iterate through all fields in my feature classes to find which fields are empty. I have tried using the SearchCursor by borrowing bits of code from other answers. This is what I have:...
1
vote
1answer
256 views

Getting ERROR 999999 when trying to use arcpy.UploadServiceDefinition_server()?

Here is my code def upload(name, client, working_dir): arcpy.env.overwriteOutput = True arcpy.SignInToPortal('https://www.arcgis.com', username, password) outdir = working_dir + "\\PROJECTS\\" +...
1
vote
1answer
118 views

Updating Cursor to Include Newly Created Features?

I am using ArcMap 10.1 and python to create cursor that starts at the one and only row of a polyline shapefile, some code runs to create a new feature based on the position of the exisiting feature, ...
0
votes
1answer
36 views

Run code on pressing a key in Pythonaddins

I tried making an addin having below code where I want the user to press a predefined key and the "required_code" should run on the selected features. import arcpy import pythonaddins class Key1(...
2
votes
1answer
280 views

Make Feature Layer from Query Layer yields an ArcPy error?

My project starts from a MXD containing Query Layers. I have to prepare the data in this "MasterMXD" for use in an offline application. Working with ArcMap 10.2.1 for this project. My Python script ...
3
votes
0answers
95 views

Arcpy 'Append_management' much slower than ArcMap Tool?

Basically I have a script that grabs data from a web service, parses it, stores it in an intermediary local fgdb, then appends that data to the feature class in the enterprise gdb. The portion of the ...
3
votes
0answers
804 views

ArcMap runs custom script once and then it crashes on second run [closed]

So I made a script that takes data from an MSSQL database and inserts it into a featureclass. I added the script to a toolbox and am able to run the tool from within ArcMap 10.1. The problem is that ...
0
votes
1answer
41 views

Multiple vertices after editing giving wrong start and end x, y co-ordinates [closed]

Initially I generated some polylines across the river at various locations. I found some of them are smaller in size and not fitting the river width, Therefore, I edited those using advanced editing ...
0
votes
1answer
88 views

ImportMapServerCache_server not executed

I have this script based on an export from Model Builder (ArcMap 10.4) that is supposed to take .tif files from a directory and import them to an existing service. The problem is that ...
0
votes
1answer
47 views

ArcPy: Excel to Table Conversion on multiple Excel files in a folder

I am trying to convert all of xls files (including single sheet) a folder into dbf tables in a gdb. Here is my code: import arcpy, os, xlrd arcpy.env.overwriteOutput = True arcpy.env.workspace = "C:...
1
vote
0answers
12 views

ArcGIS Pro PostgreSQL SSH connection string

I am involved in a project where a SQL Server-base application is being retired and replaced with a PostgreSQL/PostGIS-based tool under development. There is a large amount of cross-checking to be ...
1
vote
1answer
27 views

Framing argument for insert cursor when writing geometries using ArcPy?

I am writing polygon geometries and I have points holding the geometries that represent vertices of the polygon. When I run the code below I get: TypeError: sequence size must match size of the ...
0
votes
0answers
14 views

Attempting to run find closest facility tool in ArcPy and get no output

I try to run the Find Closest Facility tool within python to find nearest hospital around an incident. The code is shown below: tbx = "http://logistics.arcgis.com/arcgis/services;World/ServiceAreas;...
5
votes
3answers
8k views

Importing arcpy in Spyder

I can't import arcpy in spyder but I don't have any problem when using PyScripter. The error that I get is: ImportError: No module named 'arcpy' I would prefer using Spyder, if I can solve this, any ...
0
votes
0answers
21 views

Exporting webmap into PDF without layout using ArcPy with ArcGIS Pro

I try to export a webmap in using arcpy into a pdf. This works fine, if there is a Layout available using: aprx = arcpy.mp.ConvertWebMapToArcGISProject(webmap, None, None, notes_gdb) aprx....
2
votes
1answer
20 views

Extracting Summary Statistics value with cursor and assigning it to a variable

I am writing a script (to be used in ArcGIS 10.7.1) that uses a Zonal Statistics tool to create an average of a raster that is beneath a grid. I then use the Summary Statistics tool to take the ...
2
votes
1answer
762 views

Code to merge files in subdirectories not producing expected result using ArcPy

The short python code below is intended to merge a series of files (GIS files) which are contained in a series of subfolders. import arcpy import sys import os PointsMerged = r"C:\GIS\...
0
votes
0answers
23 views

Dissolve work well in my desktop but not in ArcPy [closed]

I want to dissolve in my ArcPy code but code below return nothing in my result shapefile and I try using the dissolve in ArcMap, it works well. I am wondering is it because the data or my code? ...
0
votes
1answer
30 views

Rebuilding indexes in file geodatabase using ArcPy

I am trying to automate the rebuild of file geodatabase indexes using ArcPy v10.6, but I encounter an ERROR 000837 The workspace is not the correct workspace type. Question: If arcpy....
1
vote
1answer
20 views

Arcpy Clip Raster not setting clipped out area to NoData

I have an 8 bit raster that I'm clipping using arcpy 10.7 arcpy.Clip_management("inrasPATH","","outrasPATH","PolygonPATH","256","ClippingGeometry","MAINTAIN_EXTENT") However whenever I clip the ...
0
votes
0answers
16 views

arcpy.intersect_analysis returning blank shape file

Why Intersect_analysis function of arcpy do not work as it should. Take an example of below code written behind the button click. arcpy.Intersect_analysis(inputlyr, namE[3]) ct8 = int(arcpy....
0
votes
0answers
53 views

AttributeError: 'module' object has no attribute 'xxx'

I'm trying to reduce a workflow; wherein I take a polyline file, add points every 1700m and split the polyline at those points. I then use this new split polyline file as an index for data driven ...
1
vote
0answers
1k views

Creating multiple feature classes from multiple text files using ArcPy [closed]

I have a folder with multiple text files. I am writing a code that reads all of the text files, and creates a point feature class (i.e. a shapefile) for each one. The text files are all tab ...
1
vote
1answer
1k views

Exporting Raster to JPEG in ArcPy

I built a model to import table data, create xy event, kernel density and clip density raster. I would like to export the clipped raster as a JPEG but I am not sure how to write the ExportToJPEG code. ...
-2
votes
0answers
24 views

Why aren't rows being populated when doing insert cursor? [closed]

I created a table in ArcGIS Pro using ArcPy. I was able to create the fields, but when I try to insert values into the rows using the insert cursor it doesn't populate and won't show up in the table. ...
0
votes
2answers
43 views

ExportToPNG produce empty image

I am using ExportToPNG (in ArcGIS 10.3.1) to produce images from a MXD with WMS data. If I use the interface command ExportMap with the option "1-BIT_MONOCHROME_THRESHOLD" and a threshold at 256, the ...
1
vote
1answer
37 views

Improving ArcPy script for ArcMap to only return rows of selected polygons instead of all polygons in layer

I am debugging a code provided to me that merges two polygons and alters the fields of "FID1' and "CALC_AREA." I have realized that the current code searches every layer in the map document for ...
0
votes
1answer
71 views

Creating Vector Tile Package from basemap with ArcPy?

I am trying to create a vector tile package from a basemap with arcpy, but get the using arcpy.management.CreateVectorTilePackage() causes me an ERROR 001856: Cached scale doesn't match tiling scheme. ...
1
vote
1answer
21 views

Specifying grid width and height dimensions with ArcMap custom toolbox parameter

I am using I am writing a script to create a tool (in ArcMap 10.7.1) that involves overlaying an agricultural field with a specific grid size. I need the grid to contain a custom width and height of ...
0
votes
1answer
41 views

Sharing WebMap through Python

I already know how to share a layer, or create a empty webmap (and add layers after its creation) through Python on ArcGIS Pro. However I could not find a way to share a Web Map trough Python. By ...
1
vote
1answer
15 views

List fields in parameters from Fc list in script validation using arcpy in arcgis

I am trying to list fields from a feature class list in script tool validation. First user selects the data frame from the list then FC populates in next box and fields of the FC in next box. I have ...
0
votes
0answers
20 views

aggregate_points function deprecated in ArcGIS… any work arounds? [closed]

So I have been working with the python api for ArcGis and ran into a problem. I learned that the aggregate_points function is depreciated and was wondering if there is a work around to this problem? ...
1
vote
1answer
73 views

Randomly subsetting % of polygons by class/attributes using ArcPy

Referring to this topic How to randomly subset X% of selected points?. I tried in ArcPy and I can't figure out how to change this code to randomly select 50% of the polygons based on the attribute (...
1
vote
4answers
4k views

Using ArcPy to copy layer in ArcMap TOC, rename copy, and paste back to TOC?

How do I make a copy of a layer in the ArcMap TOC (passed to my script as a Feature Layer), assign the copy a new name, set a definition query on it, and then add the copied Feature Layer back into ...
3
votes
3answers
4k views

Runtime error : ERROR 000358: Invalid expression using SelectLayerByAttribute in ArcPy?

I cannot for the life of me persuade SelectLayerByAttribute to work (I need to automate this for a complex script). Working in ArcMap's python console on already loaded shapefile, the format below: ...
1
vote
1answer
40 views

AttributeError from PDF Export from ArcMap Bookmark Loop

import arcpy, os, datetime folderPath = r"C:\path" dateTimeStamp = time.strftime('%Y%m%d') basename = "Flows" mxd = arcpy.mapping.MapDocument(r"C:\path\file.mxd") df = arcpy.mapping.ListDataFrames(...
0
votes
1answer
17 views

Remove layer assertion error

I am using below code to remove any layer if it has zero features in it. mxd = arcpy.mapping.MapDocument("CURRENT") aDF = mxd.activeDataFrame namE = ["No_Work_Done"] if int(arcpy.GetCount_management(...
2
votes
2answers
354 views

Using two Python Addin Combo Boxes to choose feature class first then field from chosen feature class?

Last night a student from my Udemy course about writing Python AddIns asked for: some tips for using a combo box to filter another combo box. What I am trying to do is use a combo box to select ...
1
vote
1answer
41 views

How to specify fields to use in a merge

I am using arcpy to merge multiple feature classes from a list of feature classes. They all have the same fields. Let's say they all have the fields = ['CO_FIPS', 'MILES', 'FLOOD_ZONE', 'VALID', '...
1
vote
1answer
40 views

Spatial reference data from all layers in MXD

I have a MXD with many group which has many layers. I have tried to get coordinate system data from all layers with the code from Iterating through layers in mxd and describing coordinate system. So ...
2
votes
0answers
127 views

Iterating through layers in mxd and describing coordinate system

I have mxd's that have information loaded from many different locations (some FCs from FGDB, shps, FCs in EGDB) and I want to check the coordinate reference system quickly for them. I have attempted ...
1
vote
1answer
21 views

Defining one numeric variable by defining another string variable (via parameter selection)

I'm creating an ArcGIS tool that will allow users to figure out how much nitrogen that a field needs based on interpolated points (Kriging). I will have the following parameters: #numeric variables ...
2
votes
1answer
85 views

Changing min max of Stretched Raster with ArcPy?

I have two rasters r1 & r2: Maximum cell value of r1: 0.9 Maximum cell value of r2: 0.3 Minimum value for both is 0 I am using a color gradient: white - yellow - green - blue - red - black ...
3
votes
2answers
275 views

Layers visibility- code error in Arcpy

I try to turn of all the layers, using this code using ArcGIS 10.3.1: import arcpy from arcpy import env env.workspace = r"G:\desktop\gis" for mxd in arcpy.ListFiles("*.mxd"): mapdoc = arcpy....
1
vote
0answers
27 views

Error in ArcPy script building network

I am trying to use the network analysis toolset to build a route. I made the the tool in model builder initially and have tried to edit it to make it a script. When I try to build the network I get ...
1
vote
1answer
33 views

Kriging error when writing ArcPy script (ERROR 000622 & ERROR 000628)

I am trying to write an ArcPy script that uses Kriging to interpolate various nutrients in the soil (i.e. nitrogen) using ArcGIS Pro 2.4.0. These nutrients were collected by sampling the soil, so it ...
3
votes
1answer
141 views

Masking LiDAR points to create DEM in ArcGIS Pro with ArcPy?

I have an irregular LiDAR point cloud dataset, so when I try to create a DEM or DSM, the points are connected across the irregular edges of the LiDAR point cloud. I thought that creating a mask ...
-1
votes
1answer
21 views

ArcPy: Delete field loop with if exception

Am new to ArcPy , am trying to join the same features from different geodatabase but I don't need all of attributes, so want to make a loop to find each feature class and delete the fields I don't ...