|
POST
|
Thanks for your help @Anonymous User . Unfortunately, when I tried your suggestion... aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("811Tickets")[0]
lyr = m.listLayers("AZ811 BlueStake")[0]
lyt = aprx.listLayouts()[0]
mf = lyt.listElements("mapframe_element", "MainMapFrame")[0]
lyrExt = mf.getLayerExtent(lyr, False, True)
mf.panToExtent(lyrExt)
mf.camera.setExtent(lyrExt) I found that it works the same as... aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("811Tickets")[0]
lyr = m.listLayers("AZ811 BlueStake")[0]
lyt = aprx.listLayouts()[0]
mf = lyt.listElements("mapframe_element", "MainMapFrame")[0]
mf.camera.setExtent(mf.getLayerExtent(lyr, False, True)) I'm trying to stay at a scale of 1:25,200, but the both of these scripts zoom to the feature's/layer's extent. If I figure it out, I'll post my corrected script.
... View more
07-28-2023
02:13 PM
|
0
|
0
|
2608
|
|
POST
|
I've written an arcpy script that pulls coordinate data from a saved email/text file. I've also added the polygon created into a feature class, and used a definition query on the layer so that the new feature is the only one visible in the map. What I'm trying to do is pan the layout's map frame to the new extent of the layer. The following script works (i.e. retains the current scale of the map frame, and pans to the layer), but it throws the included error. I'm running my script in ArcGIS Pro 2.9. I've already read the MapFrame and Camera classes https://pro.arcgis.com/en/pro-app/2.9/arcpy/mapping/mapframe-class.htm https://pro.arcgis.com/en/pro-app/2.9/arcpy/mapping/camera-class.htm I can't find ANY examples of how to use the MapFrame panToExtent method. Please help. aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("811Tickets")[0]
lyr = m.listLayers("AZ811 BlueStake")[0]
lyt = aprx.listLayouts()[0]
mf = lyt.listElements("mapframe_element", "MainMapFrame")[0]
mf.camera.setExtent(mf.panToExtent(mf.getLayerExtent(lyr, False, True)))
Traceback (most recent call last):
File "<string>", line 6, in <module>
File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\_mp.py", line 389, in setExtent
return convertArcObjectToPythonObject(self._arc_object.setExtent(*gp_fixargs((extent,), True)))
TypeError: Camera.setExtent() missing required argument 'extent' (pos 1)
... View more
07-28-2023
01:39 PM
|
0
|
5
|
2616
|
|
POST
|
I mostly figured it out! However, it created another Query 1 with the correct definition query, and it added the definition query to both maps. See my code below. aprx = arcpy.mp.ArcGISProject("CURRENT")
ticketNo = "2023070700400.002"
fieldname = "tktNum"
newName = str.format(ticketNo)
for m in aprx.listMaps():
for l in m.listLayers("AZ811 BlueStake"):
if l.supports('DefinitionQuery'):
#Get the list of definition queries
dql = l.listDefinitionQueries('Query 1')
#Clear active definition query, update will fail if there is already an active query
for dq in dql:
dq['isActive'] = False
#Create a new definition query and append it to the list
dql.append({'name': 'Query 1', 'sql': """{} = '{}'""".format(fieldname,newName), 'isActive': True})
#Update the definition queries with the newly modified list
l.updateDefinitionQueries(dql) Now, I just need to figure out how to have just the one definition query on the layer. Thanks for your help @DanPatterson !
... View more
07-27-2023
12:32 PM
|
0
|
0
|
1981
|
|
POST
|
@DanPatterson, Thanks for your help. I've been working on adapting example 4, but I keep getting an error. I think it has to do with the ticketNo = "2023070700400.002". That field in my feature class is a text field. I've tried tickeNo = str(2023070700400.002) and I get the same error. Of course it could have to do with my sql query. I'm stumped. Thanks for ANY help that you can offer. aprx = arcpy.mp.ArcGISProject("CURRENT")
ticketNo = "2023070700400.002"
m = aprx.listMaps()[0]
l = m.listLayers("AZ811 BlueStake")[0]
if l.supports('DefinitionQuery'):
#Get the list of definition queries
dql = l.listDefinitionQueries('Query 1')[0]
#Clear active definition query, otherwise the update will fail if there is already an active query
for dq in dql:
dq['isActive'] = False
#Create a new definition query and append it to the list
dql.append({'name': 'Query 1', 'sql': "tktNum = ticketNo", 'isActive': True})
#Update the definition queries with the newly modified list
l.updateDefinitionQueries(dql)
Traceback (most recent call last):
File "<string>", line 10, in <module>
TypeError: 'str' object does not support item assignment
... View more
07-26-2023
01:23 PM
|
0
|
0
|
2008
|
|
POST
|
@DanPatterson Thanks for the link! Maybe I missed something. Here's the link for Pro 2.9 - https://pro.arcgis.com/en/pro-app/2.9/arcpy/mapping/layer-class.htm
... View more
07-26-2023
11:48 AM
|
0
|
0
|
2022
|
|
POST
|
I've written a python script (arcpy) that takes the text from an email containing a ticket number and lat/long coordinates. I've been able to extract the data containing the ticket number, lat/long coordinates that form a rectangle, and other data. This data is a list that updates a featureclass in a file gdb. I've also updated/changed the layout's name to reflect the ticket number. The feature class/layer is used in both the main map and a reference or inset map. The aprx has 2 maps, and one layout. What I can't figure out is how to change the layer's definition query, so that I can zoom to or pan to the new feature. I think I need to use the Cartographic Information Model (cim), but I'm not sure how to change the layer's definition query. I'm working in ArcGIS Pro 2.9
... View more
07-26-2023
10:10 AM
|
0
|
6
|
2037
|
|
POST
|
The following line of script allows me to overwrite an existing file. arcpy.env.overwriteOutput = True
... View more
07-24-2023
11:16 AM
|
2
|
1
|
2453
|
|
POST
|
What would I have to do differently to create a single DEM from 200+ LAZ files? Thanks for anyone's help.
... View more
07-17-2023
12:00 PM
|
0
|
0
|
10172
|
|
IDEA
|
I would REALLY like a MOOC specifically for getting started with arcpy and python in ArcGIS Pro. I would like the MOOC to include the Cartographic Information Model (cim) functions for automating maps and layouts. I struggle with understanding python scripting, but need to use in in Pro. Thanks for considering this idea.
... View more
07-14-2023
11:54 AM
|
4
|
0
|
713
|
|
POST
|
The above link (https://community.esri.com/ideas/13482) is no longer valid.
... View more
03-20-2023
08:40 AM
|
0
|
0
|
21689
|
|
IDEA
|
@KoryKramer, Thanks for the suggestion. Yes, it works! How can I update the extent of the new layer so that it doesn't automatically zoom to the western hemisphere? Thanks again for your help.
... View more
11-17-2022
07:44 AM
|
0
|
0
|
2435
|
|
IDEA
|
@RoseF , I want to thank you for your suggestion. I found that it's now a three step process. 1. make the new featureclass (use the geoprocessing tool Create Featureclass), 2. add the featureclass to my map, 3. append the data (also using a geoprocessing tool), making sure that I've assigned the fields correctly (there's a checkbox for mapping the fields). Hopefully, others will find this helpful.
... View more
10-31-2022
09:02 AM
|
0
|
0
|
2459
|
|
IDEA
|
RoseF, You are correct that the tool I'm referring to is the one that you right-click and select "Load data". One of my workflows requires us to load data from a temporary feature class that gets written over each time I run the tool. I can't believe that I'm the ONLY person who wants this tool. Until the tool is rebuilt for Pro, I'll try your append workflow. Thanks for your help and quick response!
... View more
09-30-2022
10:40 AM
|
0
|
0
|
2530
|
|
IDEA
|
Recreate the Load data or "Simple Data Loader tool from ArcCatalog for use in ArcGIS Pro, complete with field mapping. NOT to be used or confused with any utility network data loaders.
... View more
09-30-2022
08:58 AM
|
4
|
7
|
2603
|
|
IDEA
|
Thanks for the response, @GordonSumerling. So, what it sounds like you're saying is that Esri does not want to support my drone. It should not matter if I choose to fly a more consumer drone. The drone does support a geofencing, so I don't understand. Again, thanks for your response.
... View more
07-29-2022
08:40 AM
|
0
|
0
|
2349
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 08-07-2024 02:11 PM | |
| 1 | 06-27-2024 12:35 PM | |
| 1 | 05-17-2024 01:44 PM | |
| 2 | 05-17-2024 10:44 AM | |
| 1 | 02-13-2024 12:34 PM |
| Online Status |
Offline
|
| Date Last Visited |
3 weeks ago
|