|
POST
|
I would try to restructure the code roughly as follows: import sys, os, arcpy
import arcpy
## Works in file geodatabase
arcpy.env.overwriteOutput = True
workspace = "C:/temp/temp.gdb"
PR = "PrivateRoads"
CityLimits = 'City_Limits'
arcpy.MakeFeatureLayer_management(PR, "polyLyr")
arcpy.MakeFeatureLayer_management(CityLimits, "CitLyr")
arcpy.management.SelectLayerByLocation("polyLyr", "HAVE_THEIR_CENTER_IN", "CitLyr", "", "NEW_SELECTION")
pr_oid_to_city_name = dict()
# Add code here to use a search cursor scan the polyLyr and
# populate the dict that maps the pr oid to the city name
with arcpy.da.UpdateCursor(PR, ['OID@', 'Owner']) as cursor:
for oid, owner in cursor:
if oid in pr_oid_to_city_name.keys():
cursor.updateRow([oid, pr_oid_to_city_name[oid])
... View more
07-11-2023
04:34 PM
|
0
|
1
|
1072
|
|
POST
|
I have had good luck with the "pip install spyder" technique on 2.9 and 3.0.3, described in a little more detail here.
... View more
06-23-2023
06:31 AM
|
0
|
0
|
871
|
|
POST
|
I solved this problem by storing my arcgis credentials in the keyring associated with my windows user id. The steps are: Sign into the windows system under the same windows ID that your script run under Store the arcgis credentials in the keyring. This is how I do it from the DOS window SET PYTHON_EXE=<path to your python.exe>
%PYTHON_EXE% -c "import keyring; keyring.set_password('<keyring id - used to retrieve password>', '<your arcgis user id>', '<your arcgis password>')" In your script you can now securely (only code running under your windows ID has access to the keyring) to retrieve those credentials and use them to sign into GIS instead of using "home" arcgis_user = <your arcgis user id>
arcgis_pw = keyring.get_password('<keyring id - used to retrieve password>', arcgis_user) You will have to remember to update the keyring by running the DOS commands whenever you change your password. The 'keyring id' can by any string that you make up.
... View more
06-17-2023
07:24 AM
|
2
|
0
|
1236
|
|
POST
|
Thanks @Brian_Wilson. I only have a single script that I have to run and I don't foresee having to install additional packages so I was hoping to avoid everything related to conda (not sure if that is even possible). That said, I was able to get my script running. Here is how I did it. I had the administrator (the guy that did the install) give up full rwx access to all subdirectories of /opt/arcgis/server Made a copy of /opt/arcgis/server/tools/python (called it python_dam) Removed the code that terminates the script if not being called by the user that did the install Edited the line where wine64 invokes python to call my module cd to /opt/arcgis/server/tools ./python_dam This is what the modified file looks like #!/bin/bash
installDir=$(cd $(dirname $0)/.. && pwd);export installDir
installer=$(stat -c %U $installDir)
arcenv=$installDir/framework/etc/arcenv
if [ -f $arcenv ]; then
. $arcenv
if [ "x$DISPLAY" = "x" ]; then
. $installDir/framework/runtime/xvfb/init_Xvfb.sh
StartXvfb > /dev/null 2>&1
fi
# don't preload libjsig.so for standalone app
unset LD_PRELOAD
export CONDA_PREFIX="C:\Program Files\ArcGIS\Server\framework\runtime\ArcGIS\bin\Python\envs\arcgispro-py3"
export CONDA_DEFAULT_ENV="$CONDA_PREFIX"
wine64 "$CONDA_PREFIX\python.exe" "/home/dmorrison/cw/test_linkage_mapper.py"
else
echo "Unable to set up environment. Cannot find $arcenv"
fi
... View more
05-02-2023
02:23 PM
|
0
|
1
|
2990
|
|
POST
|
I have a Python3/ArcPy script that must be moved from Windows to be run on a Linux system. From what I understand the only option is to run it on ArcGIS Server. So I had a system set with with Ubuntu and Arcgis Server 11 (putty/ssh access only). Now I'm trying to figure out how to run my script. Reading the documentation a number of questions came up. I thought a good first step would be to start an interactive Python session from the command line, but I can't find where the interpreter is installed. How can I do that? Must I install conda and create and activate a new environment, or is there already a base Python environment created in the installation? Must I install arcgis-server-py3? Does all of this really have to be done as the user that installed the ArcGIS Server? I tried to run <arcgis_server_installation_directory>/arcgis/server/tools/python3 and it failed for this reason Would it be better to use a python 3.8 environment which is already installed on this system instead of the one installed with ArcGIS Server?
... View more
05-02-2023
09:12 AM
|
0
|
3
|
3022
|
|
POST
|
I added the 'transformation_name' parameter on the projectAs call and now I get the same results in all environments. Thanks for the pointer Dan! pt = arcpy.PointGeometry(arcpy.Point(687577.9340000004, 2134343.1621000003), spatial_reference="USA_Contiguous_Albers_Equal_Area_Conic_USGS_version")
pt_projected = pt.projectAs('4326','WGS_1984_(ITRF00)_To_NAD_1983')
print ("Projected x,y : %s,%s" % (str(pt_projected.firstPoint.X), str(pt_projected.firstPoint.Y)))
... View more
04-30-2023
06:18 AM
|
0
|
0
|
1158
|
|
POST
|
I have some simple code that projects a point. pt = arcpy.PointGeometry(arcpy.Point(687577.9340000004, 2134343.1621000003), spatial_reference="USA_Contiguous_Albers_Equal_Area_Conic_USGS_version")
pt_projected = pt.projectAs('4326')
print ("Projected x,y : %s,%s" % (str(pt_projected.firstPoint.X), str(pt_projected.firstPoint.Y))) It seems to return different results as shown below. This first is produced when running in the ArcGIS Pro 3.1 Python window and also in my Spyder/IPython environment. The second is produced when I run it in a python toolbox (and I think when I run it after publishing the toolbox to an ArcGIS Server). Can anybody explain this difference? Projected x,y : -87.63855949198765,41.938884076168215 Projected x,y : -87.63856525044517,41.93889193970926
... View more
04-29-2023
06:24 PM
|
0
|
2
|
1202
|
|
POST
|
I believe that the defaults are not applied to existing records in your feature class, but the are applied only to new records being added. To update existing records you could run arcpy.management.CalculateField
... View more
04-28-2023
07:19 AM
|
0
|
1
|
1362
|
|
IDEA
|
I'd like to do the same. I see that I can upload a zip as a "Desktop application template" and share it for others to download. So it seems to accomplish what I need but it doesn't feel quite right. Other than the possible confusion(which would be avoided by having a generic "Zip File" item type), could there be a problem doing this?
... View more
04-19-2023
07:29 AM
|
0
|
0
|
1010
|
|
POST
|
I have exactly the same problem, did you find a solution?
... View more
04-13-2023
03:29 PM
|
0
|
0
|
801
|
|
POST
|
I don't like hard coding the array indexes since they are a pain to adjust if you move around the order of the parameters. So I wrote a function to get them by name and call that at the start of the update and execute functions. # Find the parameter by name (which is set in getParametmerInfo)
def get_parm (parms, name, enforce_not_null = False):
for parm in parms:
if parm.name == name:
if enforce_not_null and (parm.value is None or parm.valueAsText == ''):
raise Exception ("'%s' has an invalid value" % (parm.displayName))
return parm
# At the start of update and execute functions, retrieve the relevant parameters by name instead of index
def execute (self, parameters):
gdbOrFC = get_parm (parameters, "GDBs_or_Feature_Classes?")
inGDBS = get_parm (parameters, "Input_GDBs")
inFCs = get_parm (parameters, "Input_FCs")
... View more
04-13-2023
06:52 AM
|
1
|
0
|
3923
|
|
POST
|
One thing I would check is on line 70, "fields" must be a python list. I can't tell how it is returned on line 62 but I suspect it is a string with a comma-separated set of values and not a true python list - just a guess
... View more
04-09-2023
04:15 PM
|
1
|
1
|
1227
|
|
POST
|
I have had good luck with the "pip install spyder" technique on 2.9 and 3.0.3, described in a little more detail here.
... View more
03-17-2023
04:53 AM
|
1
|
0
|
2811
|
|
POST
|
I was under the impression that Domains are not relevant to doing an update, but I could be wrong. I would add a print statements in your loop to verify your inputs to updateRow with arcpy.da.UpdateCursor(StSele, "State") as upd_cur:
for upd_row in upd_cur:
print (str(upd_row))
upd_row[0] = place_dict.get(upd_row[0], upd_row[0])
print (str(upd_row))
upd_cur.updateRow(upd_row)
... View more
03-07-2023
04:21 PM
|
0
|
3
|
2052
|
|
POST
|
That's a very nice program @AaronCole1 . I've been doing a lot of scraping recently and have had good luck using FeatureClassToFeatureClass. It only works on one layer at a time, you have to feed it the REST service URL, and doesn't write to JSON like you want.... arcpy.conversion.FeatureClassToFeatureClass(in_url, os.path.dirname(out_fc), os.path.basename(out_fc))
... View more
03-07-2023
04:09 PM
|
3
|
14
|
3748
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 11-18-2025 03:42 PM | |
| 1 | 11-19-2025 02:36 PM | |
| 1 | 08-11-2025 09:19 PM | |
| 2 | 08-07-2025 11:47 AM | |
| 1 | 01-18-2022 07:15 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-28-2025
04:52 AM
|