POST
|
I suppose that would work but we already have the code set up to do a quick copy of a handful of features to a new file gdb, delete the old, and rename the new. I just need a quick way to handle an exception where the shutil.rmtree command cannot execute due to a file lock.
... View more
07-16-2012
08:38 AM
|
0
|
0
|
483
|
POST
|
I am doing some error handling on a python script that loads features into a file geodatabase from SDE and then restarts an ArcServer instance. I'm stuck at the point where I try to get the process to run through an inability to delete an old file GDB due to a file lock. Here is the code I am trying (snippet from full script): try: # Delete Old File Geodatabase shutil.rmtree(OldFileGDBPath) print "Deleting Old File Geodatabase..." logging.info("Deleted %s" %(OldFileGDBPath)) # Rename New File Geodatabase os.rename(FileGDBPath, OldFileGDBPath) print "Renaming New File Geodatabase..." logging.info("Renamed %s %s" %(FileGDBPath, OldFileGDBPath)) except (IOError, TypeError, NameError) as e: print "I/O error({0}): {1}".format(e.errno, e.strerror) pass However this does nothing to prevent the un-handled exception and stops the program from running. Thoughts?
... View more
07-16-2012
07:18 AM
|
0
|
5
|
2410
|
POST
|
If it is OK to have the buildings stacked as a single point in the center of their respective administrative polygons, you could run this process: 1) Convert all administrative polygons to points using Feature to Point tool. 2) Calculate X / Y values on administrative boundary points. 3) Calculate new field in your buildings feature to equal feature name (administrative code) : see http://mappingcenter.esri.com/index.cfm?fa=ask.answers&q=1529 (9.3, you may need to research how to do this in 10) 3) Join your buildings feature with administrative boundaries feature based on administrative code. 4) Export Join, which will now have admin X / Y. 5) Right click the "SHAPE" field in your newly exported feature, select Python, click "Show Codeblock" and enter the following into the Pre-Logic Script Code: def XYsetVALUE( shape, X_value, Y_value):
point = shape.getPart(0)
point.X = X_value
point.Y = Y_value
return point Enter the following into the "Shape" box: XYsetVALUE ( !SHAPE!, !X!, !Y! ) Click OK. Your building points will move to their respective administrative boundaries.
... View more
07-16-2012
07:12 AM
|
0
|
0
|
437
|
POST
|
Great news! I got the script working. Here is the final code: ==================================================================================================== import arcpy from arcpy import env env.workspace = "E:\GasLeaksProject\2012\GasLeaks.gdb" mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] Layer = arcpy.mapping.ListLayers(mxd, "ImplausibleReads", df)[0] #arcpy.MakeFeatureLayer_management("Gas_Selection", "ImplausibleRead") # Create a search cursor, iterate through the Implausible Reads Feature, getting and zooming to respective extents and exporting layout to JPEG. rows = arcpy.SearchCursor("E:/GasLeaksProject/2012/GasLeaks.gdb/Gas_Selection", "", "", "OBJECTID") #rows = arcpy.GetCount_management("Gas_Selection") currentState = " " # Iterate through the rows in the cursor for row in rows: [INDENT] if currentState != row.OBJECTID:[/INDENT] [INDENT][INDENT] currentState = row.OBJECTID where_clause = "\"OBJECTID\"=" + str(currentState) arcpy.SelectLayerByAttribute_management (Layer, "NEW_SELECTION", where_clause ) df.zoomToSelectedFeatures() df.scale = 6914 arcpy.RefreshActiveView() arcpy.SelectLayerByAttribute_management (Layer, "CLEAR_SELECTION", "" ) arcpy.mapping.ExportToJPEG(mxd, r"E:\GasLeaksProject\JPEG\OBJECTID" + str(currentState) + ".jpeg", df_export_width=1500, df_export_height=1200, resolution=300, jpeg_quality=70)[/INDENT][/INDENT] del mxd ==================================================================================================== Thanks again!
... View more
06-28-2012
09:57 AM
|
0
|
0
|
577
|
POST
|
OK I made the changes you suggested and also changed my data sources to a local drive whereas before it was a remote connection. I also changed the SearchCursor method to specify the OBJECTID field, and also modified the "SelectLayerByAttribute" query to simply search for OBJECTID = 1 just to see if I could get it working. Here is the code I am now running: ======================================================================================================== import arcpy from arcpy import env env.workspace = "E:\GasLeaksProject\2012\GasLeaks.gdb" mxd = arcpy.mapping.MapDocument("CURRENT") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] Layer = arcpy.mapping.ListLayers(mxd, "ImplausibleReads", df)[0] # Create a search cursor, iterate through the Implausible Reads Feature, getting and zooming to respective extents and exporting layout to JPEG. rows = arcpy.SearchCursor("E:/GasLeaksProject/2012/GasLeaks.gdb/Gas_Selection", "", "", "OBJECTID") currentState = " " # Iterate through the rows in the cursor for row in rows: [INDENT]if currentState != row.OBJECTID:[/INDENT] [INDENT][INDENT] currentState = row.OBJECTID arcpy.SelectLayerByAttribute_management (Layer, "NEW_SELECTION", ' "OBJECTID" = 1 ' ) df.zoomToSelectedFeatures() arcpy.RefreshActiveView() arcpy.mapping.ExportToJPEG(mxd, r"E:\GasLeaksProject\JPEG\OBJECTID" + str(currentState) + ".jpeg", df_export_width=1500, df_export_height=1200, resolution=300, jpeg_quality=70)[/INDENT][/INDENT] del mxd ======================================================================================================== This works and exports the extent of the feature with OBJECTID = 1, but then continues exporting the same feature only with a larger extent. When I try adding the "currentState" variable to the SelectLayerByAttribute line, it does not work, and returns <type 'exceptions.SyntaxError'>: invalid syntax (JPEG.py, line 20) Failed to execute (Script). I'm oging to continue playing around with it to see if I can get it working. Thanks for your help
... View more
06-28-2012
08:04 AM
|
0
|
0
|
577
|
POST
|
That is what I figured. I will need to come up with a way to do this without using DDP. Here is what I have so far (this is solely to emulate the DDP functionality inside ArcMap for now; once it is working I will modify it to work from a standalone Python script). "ImplausibleReads" is the layer I am trying to export as DDP, which is built on the "GAS_SELECTION" feature class. import arcpy from arcpy import env env.workspace = "H:\SP1G0\Gas Leaks\GasLeaks.gdb" mxd = arcpy.mapping.MapDocument(mxd = "CURRENT") df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] Layer = (mxd, "ImplausibleReads", df)[0] # Create a search cursor rows = arcpy.SearchCursor("Gas_Selection") currentState = " " # Iterate, select and zoom to each row in the cursor and export to JPEG for row in rows: [INDENT]if currentState != row.OBJECTID:[/INDENT] [INDENT][INDENT]currentState = row.OBJECTID[/INDENT][/INDENT] [INDENT][INDENT]arcpy.SelectLayerByAttribute_management(Layer, "NEW_SELECTION", ' "OBJECTID" = currentState ' )[/INDENT][/INDENT] [INDENT][INDENT]df.zoomToSelectedFeatures()[/INDENT][/INDENT] [INDENT][INDENT]arcpy.RefreshActiveView()[/INDENT][/INDENT] [INDENT][INDENT]arcpy.mapping.ExportToJPEG(mxd, r"H:\SP1G0\Gas Leaks\JPEG\Connection_Obj__" + str(currentState) + ".jpeg", df_export_width=1500, df_export_height=1200, resolution=300, jpeg_quality=70)[/INDENT][/INDENT] del mxd This results in an error "<type 'exceptions.RuntimeError'>: Object: Error in executing tool Failed to execute (Script)."
... View more
06-27-2012
03:41 AM
|
0
|
0
|
577
|
POST
|
Thank you Jeff, that will make the process a lot cleaner. I am trying to automate this, so that when data is dumped into a feature class the script will create the data driven pages automatically and export to JPEG. Is there a way to build data driven pages without doing it manually through ArcMap?
... View more
06-25-2012
10:53 AM
|
0
|
0
|
577
|
POST
|
I am working on creating an automated process that exports data driven pages to JPEG images based on a set of joins and spatial queries inside of a map document. All of the features and tables I am working with are in an SDE environment and cannot be modified. I am going through the process manually first before I begin trying to automate everything in Python. I am stuck at the point where I need to create data driven pages based on a current selection. I have setup a join from a feature to a table keeping only matching features, and then performed a spatial query on those matching features with another feature to arrive at a final selection of 771 records out of 989. The next step is to build data-driven pages based only on these selected features, and not on the entire feature. I have gone through the documentation and have not come up with anything. Again, ideally I would not be creating a new feature, but it is looking like I may have to in a temporary workspace before setting up the map book. Thanks.
... View more
06-21-2012
07:15 AM
|
0
|
8
|
1004
|
POST
|
Can "Clip to Graphics Extent" be used in a python script utilizing the ArcPy.ExportCAD_conversion method? We are trying to export DXF tiles based on a grid layer and providing an extent makes a selection of features passing through, but does not clip the output to the proper extent, resulting in features running way outside the boundaries of each tile.
... View more
03-23-2012
09:25 AM
|
0
|
0
|
1399
|
POST
|
Yes I had the table in a .dbf, reference data in a shapefile and the address locator inside a folder.
... View more
12-05-2011
09:09 AM
|
0
|
0
|
339
|
POST
|
Has anybody else been experiencing this issue? Even copying the table to a .dbf and the reference data into a shapefile outside of a file geodatabase the process is very slow, often requiring up to 48 hours to geocode a reasonable number of addresses (<200K). The process is always run on either a new SSD or a RAM Disk. I even got the MultiProcessGeocode python script running and it is still taking forever. Before SP3 this process would take no longer than an hour...
... View more
12-05-2011
04:39 AM
|
0
|
0
|
339
|
POST
|
No I've not tried copying the locator into a folder. The operation from this morning is still running but once it's done I'll try that. I won't be able to provide you with the data as it is confidential, but thanks for the help anyway.
... View more
10-26-2011
09:36 AM
|
0
|
0
|
339
|
POST
|
I have been geocoding tables of addresses in Catalog for a few months now with great success. The process has been very quick. However, after recently installing SP3, often times the process will run like normal but then slow to a crawl after a few seconds. The table, reference data, and address locator are all within a file geodatabase on a brand new SSD drive.
... View more
10-26-2011
03:46 AM
|
0
|
8
|
822
|
POST
|
Thank you for your timely response, Brad. The address locators I am using were built by myself yesterday. I built three separate address locators: -One using the latest TeleAtlas street routing data, using US Address - Dual Ranges (v10 locator) and US Streets with Zone (9.3.1 locator) -One using a polygon feature class of parcels. using US Address - Single House (v10 locator) and US One Address with Zone (v9.3.1 locator) -And finally one using our customer service points, using the same locators as as the parcels. The locators have worked great for 347,000 out of 360,000 features which is great. My frustration has arisen in trying to get the final 13,000 features geocoded. I will look into the documentation you provided. Thank you, I'll let you know how it goes.
... View more
08-18-2011
04:57 AM
|
0
|
0
|
463
|
POST
|
Hello again, I'm still encountering this issue of the address locator / geocoding tool giving high scores (even 100) to addresses matched in the wrong zip code. If possible I would have these matches receive a score of zero as they are incorrect. I am running ArcGIS v10.0 (Build 3200) with SP2. All patches are installed including the "geocoding memory leak" patch. Also, when building an address locator from TeleAtlas street data, the geocoding service will use the zipcode field to some extent, but will still place very high scores (>95) for matches in the wrong postal boundary. I have to run a spatial join on a postal boundary layer and do a select by attributes to find the matches in the correct zip codes, which always eliminates over 95% of the matches. Also, the process seems to place low priority to Suffix and Prefix Type. An address of "12th St" will be matched with "12th Ave" and be given a very high score (>90). Also "N 12th St" will be matched with "S 12th St" with a high score (>90). Basically it seems the only field the address locator places any weight to is the street name and civic number. By the way I am not using composite locators of any kind. Has this issue been resolved? Is there a way to force the address locator to use these fields to validate a match? The geocoding functions worked wonderfully in 9.3.1 which makes this a real shame. *EDIT* I have imported the address locators from 9.3.1 and am experiencing the same issues.
... View more
08-17-2011
04:04 AM
|
0
|
0
|
463
|
Title | Kudos | Posted |
---|---|---|
1 | 02-18-2014 07:08 AM | |
1 | 02-27-2014 05:22 AM |
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|