|
POST
|
You need to make the edit session starting dependent on whether or not the Starting Editting box is checked, right now it runs regardless. I set the result of GetParameterAsText(3) to a variable(InputEdit) then created an if statement that would run if that variable was True. workspace = r'C:\Users\abc.gdb'
mxd = arcpy.mapping.MapDocument ("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]
df.scale = 350
# Set the tool parameters
InputFeatureClass = arcpy.GetParameterAsText(0)
InputField = arcpy.GetParameterAsText(1)
InputValue = arcpy.GetParameterAsText(2)
InputEdit = arcpy.GetParameterAsText(3)
if InputEdit:
#Starting Editing Session
edit = arcpy.da.Editor(workspace)
edit.startEditing(False, True)
edit.startOperation()
# SQL expression used in selecting a feature
# The equation needs to be enclosed with double quote marks, in addition, since the input FacilityID is string, it needs to be enclosed with #single quote marks.
whereclause = """{} = '{}'""".format(arcpy.AddFieldDelimiters(InputFeatureClass,InputField),InputValue)
#Select feature by facilityid (InputValue)
arcpy.SelectLayerByAttribute_management(InputFeatureClass, "NEW_SELECTION", whereclause)
df.zoomToSelectedFeatures()
arcpy.RefreshActiveView() Not sure how you would logic the ending of the edit session into your code, since it seems like what you want your code to do is zoom to the select feature ID and edit if they choose. You might have the user close the editting session within the map document itself when they are done. What sort of edits would someone be doing to this feature(geometry, attributes, etc.)?
... View more
02-17-2017
09:05 AM
|
1
|
8
|
3093
|
|
POST
|
Technically you can apply the symbology to a Layer Object either before or after adding it to a map document, you just have to have the layer object created first. Also technically you can't apply symbology to a shapefile itself, but to a layer that references a shapefile. http://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/apply-symbology-from-layer.htm I'm going to try to find a post from last week where this was discussed. Edit: Found it, should give you some decent code to work off of as well. https://community.esri.com/message/665189-changing-symbology-in-python
... View more
02-17-2017
08:37 AM
|
1
|
0
|
767
|
|
POST
|
First off, please see this post about posting code blocks in GeoNet. https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting?sr=search&searchId=9d48f2f5-f42d-415c-9ccc-672895309e54&searchIndex=0 Secondly, it seems like you are making this far more complicated than you need it to. The first search cursor is getting you each row one at a time, so why create a feature layer using the query for each row, then have to use another cursor on a new feature with a single record, why not just retrieve all the field values you need from that row with the first cursor? Also I'm not sure your syntax for setting the values for your insert cursor are correct, row don't have any methods called Shape or ID. You would need to use the method .setValue to assign a value to that row and you have to specify which field in the method(See the help here for examples, also here for documentation on row methods). Finally, nested cursors are quite slow(especially with geoprocessing operations are placed within them), so I recommend looking at Richard Fairhurst's blog on using dictionaries with cursors to help make processing for operations like this much quicker. Edit: Fixed hyperlink to Richard's Blog post
... View more
02-16-2017
08:46 AM
|
1
|
1
|
2890
|
|
POST
|
I would suggest making a Feature Layer, which would allow you to use a query to subset your data down to what you want prior to converting it to a shapefile. Then use that Feature Layer as your input for feature class to shapefile. http://pro.arcgis.com/en/pro-app/tool-reference/data-management/make-feature-layer.htm Conversely you can do a select by attribute and do something similar to this post. https://community.esri.com/thread/121098 Either way take a look at Josh Bixby's post in that link above about properly formatting SQL queries in Python, will help you get the syntax right.
... View more
02-16-2017
08:09 AM
|
3
|
1
|
2508
|
|
POST
|
Wouldn't you dictionary key return both both the value for Shape_Length and Shape@ when you use valueDict[PROPNUM] in line 28(since both are read in to the dictionary value as a tuple in lines 18 or 21? You need it to return only the values from the SHAPE@ field, so should it be row[2] = valueDict[PROPNUM][1]? I'd use some print statements to see what its trying to insert there....
... View more
02-15-2017
01:33 PM
|
1
|
1
|
2656
|
|
POST
|
Yes it is quite useful, I keep it bookmarked on my work computer and GeoNet account.
... View more
02-15-2017
09:23 AM
|
0
|
0
|
748
|
|
POST
|
I'm just going to reiterate what Neil said and recommend you check Richard's blog post about cursors and dictionaries(though he accidently tagged Richard and his page instead of that particular blog post). https://community.esri.com/blogs/richard_fairhurst/2014/11/08/turbo-charging-data-manipulation-with-python-cursors-and-dictionaries
... View more
02-15-2017
09:16 AM
|
1
|
2
|
4815
|
|
POST
|
Hi Pete, If you have the Production Mapping extension(available 10.3+ I believe), then there is a python function for setting a map documents page size. http://desktop.arcgis.com/en/arcmap/latest/extensions/production-mapping/setpagesize-function.htm If you don't have it or are using below 10.3, then unfortunately, you can read the page size property using the arcpy.mapping module by creating a Map Document object, but it is read only. http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/mapdocument-class.htm What is your current workflow you are using to update your maps? Can you link to the other questions you have had answered? Can you create a template 34x22 map to copy your layers over to or something similar(I've done this before, when I needed to move several hundred map documents from an old template to a new one.)? Edit: As always there seems to be an ArcObjects solution. If you want to dig into it at all there is a blog post about doing this https://clubgis.net/python-to-change-page-size-and-layout-for-arcmap/
... View more
02-14-2017
06:53 AM
|
1
|
1
|
2005
|
|
POST
|
If you have a layer file (.lyr) saved with the symbology you want, you should be able to have it apply to raster layers within a map document(I haven't tested this). http://desktop.arcgis.com/en/arcmap/10.3/tools/data-management-toolbox/apply-symbology-from-layer.htm Since that RGB composite does not fall under a symbology class type that is support by python, you can't change to it directly through the layer's properties(this I did check). http://desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-mapping/layer-class.htm
... View more
02-13-2017
12:23 PM
|
1
|
1
|
1402
|
|
POST
|
I think you are on the right track. You could use Search Cursor to read all the values into a dictionary, then use an insert cursor to insert the values into an empty feature class. I see you already have seen Richard Fairhurst blog on python, cursors, and dictionaries, which should get you started. Between that and using the python sorted() function, you should be able to specify which tuple returned from one of his list comprehensions you want(since you should get two tuples based on two features having the same key). As long as you specify the length value of the tuple, the longer one should always be the last one tuple in the list. Edit: I'm getting a bit out of my python depth here so take my advice with a grain of salt. Also tagging rfairhur24 for advice.
... View more
02-13-2017
11:52 AM
|
1
|
0
|
2656
|
|
POST
|
Tagging several people who might already have solutions to something like this. rfairhur24 xander_bakker timw1984 Dan_Patterson
... View more
02-10-2017
09:02 AM
|
1
|
1
|
2948
|
|
POST
|
Here is the ESRI help for that error code: http://pro.arcgis.com/en/pro-app/tool-reference/tool-errors-and-warnings/001001-010000/tool-errors-and-warnings-00901-00925-000918.htm From the help on the error code, I'd guess there is still a lock on the intermediate data after it is created, you mind posting code from where the intermediate data is created to where you run the Polygon to Raster? Also for code formatting on GeoNet https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting
... View more
02-10-2017
07:12 AM
|
0
|
2
|
2233
|
|
POST
|
Could you post some of your code you are using? Feature Layer is the correct parameter type you should be using for TOC Layers(as long as they are referencing a feature class of course), so not sure from what you've posted so far what the issue might be. Also for posting code(saw another of your posts) see: https://community.esri.com/blogs/dan_patterson/2016/08/14/script-formatting Edit: grammar changes, I think faster than I type......
... View more
02-10-2017
07:02 AM
|
0
|
0
|
1163
|
|
POST
|
Alternatively to using nested cursors, I suggest taking a look at Richard Fairhurst excellent blog post about using dictionaries and cursors for data manipulation. Should also give you a significant performance boost in processing time.
... View more
02-10-2017
06:26 AM
|
1
|
0
|
4190
|
|
POST
|
xander_bakker, Dan_Patterson, seems like your sort of playing with geometries stuff.
... View more
02-02-2017
07:50 AM
|
1
|
0
|
1813
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 02-22-2017 08:58 AM | |
| 1 | 10-05-2015 05:43 AM | |
| 1 | 05-08-2015 07:03 AM | |
| 1 | 10-20-2015 02:20 PM | |
| 1 | 10-05-2015 05:46 AM |
| Online Status |
Offline
|
| Date Last Visited |
11-11-2020
02:23 AM
|