-
Building a test environment
I am new to Python and have a few tasks that my team has been encouraging me to do. So I am nervous and excited to get into this. Background: 3 years of JavaScript work that was mainly freelance. This is my first Job in GIS. First project is to build an automated "save edits" script to run after you start an edit session.…
-
ClearWorkspaceCache: For Your "This Should Work. Why Isn't It Working?" Needs
I have been struggling for several days trying to convert a legacy Python 2/ArcMap based script to run in the Python 3/ArcPro environment. It is a multi-step, data management script that involves clearing out the old data and putting in the new data. The script kept failing before a call to TruncateTable with "ERROR…
-
Iterating through geometries in a layer for multiple if conditional statements.
I am trying to iterate through the features of a layer and verify two different variables in two different fields in the same row. If both variables are true then it will apply a geoprocessing tool with one of the 2 results. The geoprocessing is Feature vertices to Point. I want to run it to create an output with points at…
-
Area and centroid calculations
It is easy to get arcpy shapes, geojson geometry and various relatives to arrays. You can add this to your geometry arsenal. It can be used for convex/concave/multipart (including parts with holes). Clockwise (cw) geometry returns a positive area, holes (ccw) a negative one. The centroids for both parts can be weighted or…
-
Field calculator expressions with numpy
A followup to the recent einsum post, but with a field calculator twist # ---- a numeric field, python expression which uses the shape field to return the longest edge on the perimeter longest_seg(!Shape!) # ---- the code block ----- import json import numpy as np # def longest_seg(a): """Longest edge""" v =…
-
Einsum in geometry
Take a square representing a polygon or a closed-loop polyline. Let us call it aoi, perhaps out area of interest. aoi array([[ 0.00, 0.00], [ 0.00, 10.00], [ 10.00, 10.00], [ 10.00, 0.00], [ 0.00, 0.00]]) aoi.shape (5, 2) Notes: * The first and last points are the same, hence it is a closed geometry * The shape of the…
-
A simple drop in class for managing workspaces
I ran across an idea by @AlfredBaldenweck the other day in this post that raised some good points about how annoying it can be to work with the arcpy.List* functions. His solution of allowing a workspace parameter to be passed is good, but would require a lot of changes to the existing functions. This led me down a path of…
-
Flatten nested data
Replace the numbers below with anything you want. lst = [ [[1, 2, 3], [4, 5]], [[1, 2]], [1, 2], [[]], [[1, 2, 3], [4, 5], [6, 7, 8]], [[[1, 2, 3], [4, 5]], [[6, 7, 8]]], ] Flatten with recursion (a function calling itself 'recursively') def flatten(a_list, flat_list=None): """Change the isinstance as appropriate. :…
-
Child messages
In Pro, is there any way to get a child script's messages to display in the geoprocessing window (the way the parent messages do)? Thank-you.
-
Calling python scripts
Apologies for what might seem simple but... In ArcMap, it was simple to call a python script from another using execfile() I need to recreate that in Pro but nothing I try works. It doesn't matter if I'm calling a .py file or an embedded python script in a project toolbox. Some things I have tried: from…
-
Would like to append records that have been sum within'd in a drivetime result poly to original source points
I am newer to Python coding but I have a workflow that requires me to 1. run 30/60 min drive times, 2. use Split function to separate the identifiers from the Name field in the results poly 3. perform a summarize within using various demographic point features 4. and then join that 30/60 poly with the new 'sum within' data…
-
Calculate Field to get the value for field from combine data of other fileds
Hello, I try to use Calculate Field to get the value for field “DESCRIPTION” from combine data of other fileds, as the image 1 attached. However, my below first Syntax is not working arcpy.CalculateField_management(UT_CROSSING, "DISCREPTION", "[COMPANY]+\" \"+ [LOCATION]+\" \"+ [TYPE]+\" \"+\" SIZE=\"+ [SIZE]", "VB", "")…
-
python console fails
FYI, I did have a respectable early stage Geonet profile going, but had to abandon that profile in switch over to this account. I am good with Python and am experienced in ArcMap (not yet Pro - thinking I should). An major ESRI bug that I'm sick of working around: Why does the Python console basically stop working…
-
Update Postgres Query with arcpy
Hi, I have a number of layers that i'd like to update the source tables for in an ArcGIS pro Project. The layer sources are postgres database connections. I have been able to change the "dataset" value in the connectionProperties, but tthis doesn't not change the value of "query" in the properties as "dataset" seems to…
-
How to change the dynamic text tag for maximum value in a field using Arcpy.mp?
Hi Everyone: I have successfully produced a map with title, legend and statistics (number, maximum, minimum, mean). I did this within ArcPro through the desktop application, creating a template. Now I want to produce many maps, but only changing the column of data or "field" in the corresponding attribute table. I only…
-
Create a Raster Colorizer ArcGIS Pro?
I have a single band NDVI raster that I would like to Classify through Arcpy. I've been struggling to find the documentation in order to create a colorizer object. So basically I've hit a wall after creating a lyr.symbology object in order to update the layer. If I manually create the Symbology in the contents window, then…
-
How to make code loop instead of running with specific files one at a time
Hi Everyone: I have this code that works: if not hasattr(sys, 'argv'): #only use if system has issue with relpath command sys.argv = [''] import arcpy, os, sys, locale relpath = os.path.dirname(sys.argv[0]) p = arcpy.mp.ArcGISProject(relpath + r'C:/Users/ggrodzinsky/Documents/ArcGIS/Projects/MyProject8/MyProject8.aprx') m…
-
Python script stopped working. Need help
I have a small Python script that essentially downloads a zip file, unzips it, and saves the contents (shapefiles) to a folder on my network. It stopped working not too long ago and I'm not sure why. I was testing each line in the Python Consol, and when it got to the last line shown below (zipresp = urlopen(zipurl)), it…
-
how can I fix it...
Good morning, Hello dears, Last Tuesday i was trying to create Map used by Arcpy and two days also. I was using If-elif-else statement. but i was face face issue. which i attach in bellow. Please help me to find that problem....
-
Issues with 64 BIT Arcpy Scripts
Unable to use the 64 Bit Arcpy modules to list table or print records or do anything on a non sde geodatabase where as the same code works absolutely fine with 32 Bit arcpy modules. Doing this simple process and I'm stumbled to understand why this is not working in 64 Bit import arcpy # Set the current workspace table =…
-
max value of a field as variable
Hello, With the following script I was able to determine the maximum values of a column [POINT_Z] for certain groups from [ID_1]. <SPAN class="comment token">#creating a list ->"mast_value" with unique values of field [ID_1]</SPAN> <SPAN class="keyword token">with</SPAN> arcpy<SPAN class="punctuation token">.</SPAN>da<SPAN…
-
Field calculation issue when using memory workspace
Hi all, I'm working on a script that uses the 'memory' workspace as layers are being processed, and I've hit an issue when I try to execute a field calculation between joined layers. I have included a script below that demonstrates the differences between workflows - the calculation will work fine if I create the feature…
-
arcpy CalculateField - combine field values and derived value
Newbie here. I've been trying to solve this for weeks and have searched and tried many suggestions from this site and still can't get this to work correctly. I'm trying to use a derived value (max) from the Value field of a raster and use it in a calculation on each row of that field, and put the results in a new field…
-
Arcpy error.
I am currently trying to write a script that iterates through files in a folder to do geoprocessing. However, I am getting held up at the very start of my code with an error I cannot explain or find an answer to. I am basically a novice at Python scripting, however, I have used arcpy and pyscripter successfully throughout…
-
ArcGIS Pro 2.5.0 - ArcPy issue - VERY DANGEROUS
To whom it may concern A recent update for ArcGIS Pro 2.5.0 and ArcPY will cause serious issues to features and shapefiles. While testing some code I wrote between myself and our GIS analyst, I found something very odd occurring with the following sample code snipet. arcpy.management.CalculateField(currentFeature,…