1,015 reputation
311
bio website
location Mankato, MN
age 27
visits member for 2 years, 3 months
seen 4 hours ago

7h
comment List all feature layers
No problem, using the globals() will return a dictionary of the variable names and their respected values. The dir() returns a list of the variables. The line you are asking about is just a list comprehension that checks to see if the variable type is an arcpy.mapping.Layer, which is the data type returned from the MakeFeatureLayer() function. If a variable is of the layer type, it is added to the list.
Dec
15
comment name 'row' is not defined error appears overnight
That is strange, I do not know why it would say "porow" is not defined. Are there any feature classes with 0 records? Maybe you could do a try: del porow, except: pass, finally: del pocursor. That way at least the cursor object gets deleted at every iteration and it should not fail with that error.
Dec
15
comment name 'row' is not defined error appears overnight
Try moving your MakeFeatureLayer outside of the loop and remove the clear selection and Delete_management() routines at the end. It should take on a new selection every time.
Dec
15
comment name 'row' is not defined error appears overnight
Can you post your full error message?
Dec
9
comment Merge tif files with python
Just a thought, setting sys.argv as you are may be causing a problem. sys.argv[0] is always the path of the current script running. Whenever I pass in args in this way I usually do sys.argv[1:] = [#your args here]. I should add that when I do that, it is when using ArcGIS/arcpy so it may not apply for gdal.
Dec
5
comment Set default values for value table in Python Toolbox tool
Beautiful! I can't believe I missed that...It seems so obvious. Thank you very much!
Dec
4
comment Arcpy SelectByAttributes and Show Selection
I just edited my original answer to include that information. I hope it helps.
Dec
4
comment Arcpy SelectByAttributes and Show Selection
There is, you can just set the mxd variable to be the current map like this: mxd = arcpy.mapping.MapDocument('current'). You could also set up validation to list the layers in the mxd as a drop down then have a where clause parameter to give you the Select By Attribute GUI, which would be obtained from the layer you choose.
Dec
4
comment Arcpy SelectByAttributes and Show Selection
Yes, but if you are using a stand alone script the map has to be closed. You have to reference the layer by name using the lyr = arcpy.mapping.ListLayers(mxd, 'layer name')[0]. Once you have referenced the layer, you can run the select by attribute and then save the map using mxd.save(). Next time you open it, there should be a selection.
Dec
3
comment Set default values for value table in Python Toolbox tool
Thanks for the suggestion. I tried that in the getParameterInfo() method with both adding rows to the vt param object itself and creating a new value table, adding the rows and setting the vt.value to the new value table with still no luck. I don't think I can use this in the ReorderFields instantiation because the fields are dependent on an input feature class. Maybe I can make a value table object in the init and try setting the vt.value to the self.valueTable once the rows have been populated.
Nov
21
comment Converting personal geodatabase .mdb file to .gdb
You should be able to do this without any scripting. Just create a new file geodatabase, and by using ArcCatalog you can select all the feature data sets/feature classes in the personal gdb and copy and paste them into the new file gdb.
Nov
18
comment Why is the result of a raster calculation integer when it should be decimal?
It would help if you posted your Raster Calculator expression.
Nov
14
comment Measuring distance between two points?
if you have ArcInfo, you can use the Near tool. Otherwise, some basic geometry with the coordinates works too.
Nov
14
comment findAndReplaceWorkspacePaths does not work for sde files so as to change datasouce (geodatabase)
Hmm, maybe try using the path r"Database Connections\DB1.sde". This is an alias for the exact same path you are using, but maybe some stuff under the hood will validate it properly.
Nov
13
comment Is there a Python script to identify which database features are in Map/Feature Services?
I don't have any examples using xml.tree readily available, but I do know that module is pretty straightforward to use. I did edit my response to add some code for how to unzip a file. Honestly, I think the easiest way would be to just loop through the mxd that was used to create the service if you know where those are.
Nov
7
comment Problem writing list of features to text file
One thing that would also be more efficient would be to just write a new txt file instead of opening and appending the file at each iteration. You could use a with statement with the 'w' mode.
Oct
31
comment set extent for jpeg programmatically
That almost worked...Unfortunately, the returned images from the REST API do not seem to match the extent that is returned with the image. I tried to shift by the upper left corner (xMin, yMax) and it is off by about 35 meters on the y-axis.
Oct
30
comment set extent for jpeg programmatically
Yes, the coordinates come in at 0,0.
Oct
30
comment set extent for jpeg programmatically
Right, I am able to set the projection and I even tried to run the convert raster to other format tool with an output extent environment set to the extent shown in the picture above. No dice. I should also add that these services do not support rendering/raster functions so I cannot use the Clip shown here: resources.arcgis.com/en/help/arcgis-rest-api/index.html#//…
Oct
28
comment Best way to get a bounding polygon of all features in a file .gdb
No problem, saving files "in_memory" creates temporary gdb's in the RAM. It is supposed to be automatically deleted after the script runs. The help docs explain it better than I can: resources.arcgis.com/en/help/main/10.2/index.html#//…