DOC
|
Hi, @Luke_Pinner. I tried steered to C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\python.exe and did the rest of the settings as noted above. However, PyCharm pointed at whatever ArcGIS Pro uses (3.7 I think). I still get errors with PyCharm. I have not problems using the python window in Pro. So I'm frustrated. I don't use or have a cloned environment, but I'll look into. If I get any success with PyCharm, after the eclipse, I'll leave a comment.
... View more
2 weeks ago
|
0
|
0
|
199
|
DOC
|
Thanks, @BlakeTerhune . That worked, but PyCharm says "No module named arcpy" on my first line "import arcpy". PyCharm interpreter is set for 2.7 import arcpy
# Set the workspaces
aprx = r"P:\GIS_Workspace\AZ811andPython\AZ811_Task.aprx"
# aprx = arcpy.mp.ArcGISProject("CURRENT")
arcpy.env.overwriteOutput = True
# It would be better if I could just have the email copied into an input field in a task or toolbox.
tbl = r"P:\GIS_Workspace\AZ811andPython\AZ811_Python.gdb\tempEmailText"
field0 = ['Ticket']
field1 = ['Email_txt']
with arcpy.da.SearchCursor(tbl, field0) as tCursor:
for row in tCursor:
myTicket = u'{0}'.format(row[0])
az811txt = "AZ811Ticket" + myTicket + ".txt"
tktPath = "P:\\GIS_Workspace\\AZ811andPython\\AZ811_emails\\"
az811File = tktPath + az811txt
del tCursor
with arcpy.da.SearchCursor(tbl, field1) as eCursor:
for row in eCursor:
email = u'{0}'.format(row[0])
# Write email to a text file
with open(az811File, 'w') as f:
f.writelines(email.replace('\n', ''))
del eCursor .
... View more
2 weeks ago
|
0
|
0
|
282
|
DOC
|
This PyCharm Setup for ArcGIS Desktop is outdated. This procedure doesn't seem to have the same info for setting PyCharm up for use in ArcGIS Pro 3.0. Can someone point me to a more applicable source? Thanks a Bunch
... View more
2 weeks ago
|
0
|
0
|
290
|
POST
|
@SteveCole , I seem recall from a python class that you need to "del" your "theCursor" to close the table/layer. So on line 77 in your script put "del theCursor" at the far left. You may already know that, but the documentation doesn't really mention anything about deleting cursors, when you're done with that table. I hope that helps a little.
... View more
03-18-2024
11:43 AM
|
0
|
1
|
179
|
POST
|
Your little script is almost correct. I had to change nam[0:1] to nam[0:2], because the "c" got skipped and yielded MDavid. The following works, and yields McDavid. Thanks so much!!! def FindLabel ( [STN] ):
nam = [STN].lower()
nam = nam.replace("mc", "Mc")
nam = nam[0:2] + nam[2].capitalize() + nam[3:]
return nam
... View more
02-13-2024
12:34 PM
|
1
|
1
|
331
|
POST
|
That partially works. STN.replace("MC", "Mc") returns McDAVID. What I want is McDavid. Thanks for your help. I'll keep trying.
... View more
02-13-2024
12:09 PM
|
0
|
3
|
344
|
POST
|
I have a featureclass of street names where all of the names are in uppercase. I can set a label class using an expression STN begins with "MC%", but I want python to label the streets starting with MC to convert the label to proper case, for example, MCDAVID would be McDavid. Does anyone have a suggestion for using python to do this? I've already tried using [STN].title(), but that yields Mcdavid. Thanks for the suggestions.
... View more
02-13-2024
10:09 AM
|
0
|
6
|
419
|
IDEA
|
@Bud , you sort of can. I create a polygon from four lat./long. coordinates. I collect four sets of coordinates from emails for marking utilities. I think that the array is actually a list, but in this instance it works like an array. After this portion of code, I use an UpdateCursor to add attributes to the new polygon in a feature-class. FYI, I'm still on Pro 2.9, so I'm using arcpy version 2. fc = r"C:\myPython.gdb\AZ811_BlueStake"
iCursor = arcpy.da.InsertCursor(fc, ["SHAPE@"])
array = arcpy.Array([arcpy.Point(lonX_NW, latY_NW),
arcpy.Point(lonX_NE, latY_NE),
arcpy.Point(lonX_SE, latY_SE),
arcpy.Point(lonX_SW, latY_SW)])
# Spatial reference set to GCS_WGS_1984
spatial_reference = arcpy.SpatialReference(4326)
polygon = arcpy.Polygon(array, spatial_reference)
iCursor.insertRow([polygon])
del iCursor
... View more
10-31-2023
02:07 PM
|
0
|
0
|
350
|
POST
|
#JasmineSpring, one thing you need to do after using any cursor, is you need to del the cursor. Your code should look something like this... import arcpy
# Get the selected layer
layer = arcpy.GetParameterAsText(0)
# Create a list of field names starting with "poa"
poa_fields = [field.name for field in arcpy.ListFields(layer) if field.name.startswith("poa")]
for field in poa_fields:
with arcpy.da.UpdateCursor(layer, poa_fields) as cursor:
for row in cursor:
if row[0] is None:
row[0]="1"
cursor.updateRow(row)
del cursor
# Use the Field Calculator to calculate the product
expression = "1" if not poa_fields else " * ".join([f"!{field}!" for field in poa_fields])
arcpy.CalculateField_management(layer, "Product_poa", expression, "PYTHON") (see line 15).
... View more
10-25-2023
03:24 PM
|
0
|
1
|
612
|
POST
|
Here's an earlier post "Programmatically select layer definition query" found here https://community.esri.com/t5/arcgis-parcel-fabric-questions/programmatically-select-layer-definition-query/td-p/1114999 See also - "Delete vs deactivate layer definition query"- https://community.esri.com/t5/python-questions/delete-vs-deactivate-layer-definition-query/m-p/1313695
... View more
09-21-2023
10:17 AM
|
0
|
0
|
725
|
POST
|
#xavro, here's a link that will get you started. https://pro.arcgis.com/en/pro-app/latest/arcpy/get-started/specifying-a-query.htm
... View more
09-21-2023
09:40 AM
|
0
|
0
|
772
|
POST
|
I've had the same problem. I am forced to set the map's layout scale after my feature is drawn from the x/y coordinates. Here's a snippet of what I do after running a script that collects data from a "utility marking request" that draws the feature from Lat/Long coordinates. lyt = aprx.listLayouts()[0]
mf = lyt.listElements("MAPFRAME_ELEMENT", "MainMapFrame")[0]
mf.camera.setExtent(mf.getLayerExtent(lyr, False, True))
mf.camera.scale = 24000.0 After the script runs, I have to zoom to the feature using Pro (version 2.9). I think Esri needs to make the getLayerExtent() to allow for a percentage, like when you "zoom to selected feature" or for a map book layout where you can set a percentage for the feature extent in Pro. Maybe you could submit it as a Python Idea. Just a thought.
... View more
08-23-2023
12:37 PM
|
0
|
1
|
488
|
POST
|
@adamwade1 , the only solution that I found to work was to use the function provided by @RogerDunnGIS on 02-02-2023 08:37 AM (see above in this thread).
... View more
08-16-2023
12:00 PM
|
0
|
0
|
1475
|
POST
|
I tried to set the definitionQuery property to "" and None. All that happened was the layer's definition query was made inactive and the new definition query was created and made active. Thanks for your advice. I will just have to accept that I will have to delete the old definition query from within the aprx.
... View more
07-31-2023
04:11 PM
|
1
|
0
|
583
|
POST
|
I finally figured out how to REMOVE/DELETE the definition query from a specific layer in a specific map. Ultimately, I used the Cartographic Information Model (cim) to access the definitionExpression. I read through the Python CIM access web page. https://pro.arcgis.com/en/pro-app/2.9/arcpy/mapping/python-cim-access.htm In my aprx file, I right-clicked the map's name and selected "Save As Map File" the map(s), and them opened the *.mapx file as a *.json file. Next, I searched through the file for the "definitionExpression" field. After trying a bunch of things, I finally found that I want to change the layers "featureTable.definitionExpression" to equal "". Here's my code. import arcpy
# Reference a project, map, and layer using arcpy.mp
aprx = arcpy.mp.ArcGISProject('current')
m = aprx.listMaps("Inset")[0]
lyr = m.listLayers("AZ811 BlueStake")[0]
# Return the layer's CIM definition
cim_lyr = lyr.getDefinition('V2')
# Modify the featureTable.definitionExpression
cim_lyr.featureTable.definitionExpression = ""
# Push the changes back to the layer object
lyr.setDefinition(cim_lyr)
... View more
07-31-2023
01:50 PM
|
1
|
3
|
587
|
Title | Kudos | Posted |
---|---|---|
1 | 02-13-2024 12:34 PM | |
1 | 07-31-2023 04:11 PM | |
1 | 07-31-2023 01:50 PM | |
2 | 07-24-2023 11:16 AM | |
4 | 07-14-2023 11:54 AM |
Online Status |
Online
|
Date Last Visited |
6 hours ago
|