|
POST
|
If the code works fine on all other maps, and only crashes on one map, something is likely off with that one map. I have run into issues where MXDs are partially corrupt, not too corrupt for ArcMap to open but corrupt enough that ArcPy scripts will crash. Have you run DocDefragmenter or MXDDoctor on the problem map? If not, it might be worth seeing if running either of those makes a map that doesn't crash. If the MXD is healthy and defragged, there might be a data source in the map that is exposing a bug with ArcPy.
... View more
08-29-2015
07:29 AM
|
0
|
8
|
2978
|
|
POST
|
Try an upper-case "L" after mapping instead of lower-case. The lookup or autocomplete is case sensitive.
... View more
08-28-2015
01:57 PM
|
1
|
1
|
8684
|
|
POST
|
ORA-12154 is a naming or connection identifier resolution error. How is your client name resolution lookup configured? Are you using TNSNAMES, LDAP, EZCONNECT, etc...?
... View more
08-27-2015
01:55 PM
|
0
|
6
|
10932
|
|
POST
|
Lance Shipman, I figured out what was preventing the Whitehorse GeoPackage from loading. When working with tiles in GeoPackages, the Make Raster Layer tool appears to need the zoom levels to start at 0 and increment from there. The Whitehorse and other GeoPackages I am working with are sparse, i.e., they don't start with zoom level 0, so they fail to load. If I go in and reset the zoom levels to start at 0, then I can get them to load. The fact that Make Raster Layer seems to need the zoom level to start at 0 is in violation of the GeoPackage standard as I read it. The standard specifically has a couple lines that state, "Tiles MAY or MAY NOT be provided for level 0 or any other particular zoom level. This means that a tile matrix set can be sparse, i.e. not contain a tile for any particular position at a certain tile zoom level."
... View more
08-27-2015
01:33 PM
|
1
|
0
|
3900
|
|
POST
|
You can use the catalogPath property of an ArcPy Describe object instead of the dataSource property of an ArcPy Mapping Layer object. I prefer this approach because often times I am working with layer names as strings instead of layers as layer objects. Also, using the ArcPy Describe function works if you are in a standalone script that doesn't involve a map document. Depending on the circumstances, I either write a normal function or a lambda function to get the catalog path, and then call the function and pass the layer name in the search cursor: dataSource = lambda in_layer: arcpy.Describe(in_layer).catalogPath
with arcpy.da.SearchCursor(dataSource(layer_name), fields) as cur:
...
... View more
08-27-2015
06:37 AM
|
2
|
1
|
2393
|
|
POST
|
Regular expressions are extremely worthwhile, especially since they are a language in and of themselves so your knowledge can be transferred beyond Python.
... View more
08-26-2015
03:18 PM
|
1
|
0
|
1812
|
|
POST
|
There are numerous ways to address this issue, some of which have already been raised here. A Google search for "python replace multiple strings" will yield even more ideas, some of them with fairly in-depth discussions. If you want to stick with using the Field Calculator, then you are going to have to use code blocks. Another option would be to use ArcPy cursors, the Data Access ones are the newest and best. An approach I have used in the past that is simple, and seems to perform well enough with my data sets, is a variation of a suggestion from a Stack Exchange/Overflow post: How can I do multiple substitutions using regex in python? import re
repls = {
'california': 'California',
'cal': 'California',
'ca': 'California',
'florida':'Florida',
'fl':'Florida'
}
def multiple_replace(text):
regex = re.compile("(%s\\b)" % "\\b|".join(map(re.escape, repls.keys())),re.I)
return regex.sub(lambda mo: repls[mo.string[mo.start():mo.end()].lower()], text) The above code goes in the code block, and the field box would be multiple_replace(!State!). A couple of notes. You will need some kind of mapping between what you want to replace and what you are replacing it with. In this example, a dictionary is being used but other Python data structures could be used as well. The posted code works on upper or lower case, but the dictionary keys need to be lowercase or you will get a Key Error potentially.
... View more
08-26-2015
03:10 PM
|
1
|
0
|
1812
|
|
POST
|
If you run the code two or three times in a row using the same dataset, does it work each time or only the first time?
... View more
08-25-2015
11:48 AM
|
0
|
4
|
2463
|
|
POST
|
From a purely Python programming perspective, having 100+ lines of code within a single try block is unusual. What does your except clause look like?
... View more
08-25-2015
08:14 AM
|
0
|
1
|
4274
|
|
POST
|
What is the specific error message, can you post it please?
... View more
08-25-2015
07:41 AM
|
0
|
1
|
4274
|
|
POST
|
What you are running into is a bug that was addressed in ArcGIS 10.3, i.e., prior to ArcGIS 10.3 the embedded service properties were not available when an SDE data source was broken. If you try on a 10.3 machine, I would be interested to see the results. Normally I would provide links to documentation, but the Esri Support and Development documentation on this bug is a mess in terms of consistency and accuracy. There is still an open bug with Esri Support even though Esri Development fixed it already.
... View more
08-24-2015
01:56 PM
|
1
|
1
|
962
|
|
POST
|
To print out the embedded connection properties for all SDE layers in an open map document: mxd = arcpy.mapping.MapDocument("CURRENT")
for lyr in arcpy.mapping.ListLayers(mxd):
if lyr.supports("SERVICEPROPERTIES"):
if lyr.serviceProperties["ServiceType"] == "SDE":
for k, v in lyr.serviceProperties.iteritems():
print "Property: {:<30}Value:{}".format(k,v)
... View more
08-24-2015
12:49 PM
|
1
|
5
|
4341
|
|
POST
|
What you are running into is expected behavior. Prior to ArcGIS 10.1, how an SDE connection file was accessed when first loading data determined whether the connection information was embedded in the map document or referenced in the map document: Bug: SDE connection information is not preserved in an MXD if a Universal Naming Convention (UNC) path is used. The issue was "addressed" in ArcGIS 10.0 SP5 and ArcGIS 10.1. Personally, I disagreed and continue to disagree that it was a bug that needed to be fixed. The embedded vs. referenced behavior was around since the ArcGIS 8.x days, even though the aforementioned KB only covers back to 9.1. Allowing for SDE connections to be referenced instead of embedded allowed for flexibility in managing large swathes of SDE layers, but I guess it was too complicated for most users to get their head around. Alas, everything was changed to embedded. Now that SDE connection properties are embedded, it is important to always use/check the embedded properties in the map document and not use a Describe object to look up the connection properties of an SDE connection file referenced with the workspacePath. It is completely possible that an SDE connection file referenced with workspacePath could have different connection properties than when it was used to load data into a map document.
... View more
08-24-2015
11:38 AM
|
1
|
8
|
4341
|
|
POST
|
I gave up on dealing with invalid/irregular polygons in ArcPy, or really even ArcGIS, a few years back. I kept running into polygons that were invalid but the standard Esri tools couldn't identify them. Eventually, I threw in the towel and now use Safe Software's FME product to do my polygon validation when I run into problems. When access to FME isn't available, I sometimes convert ArcPy Polygon objects to Shapely or GeoDjango geometries to find invalid polygons. It is all a bit kludgy, but I got tired of fighting with Check Geometry and Repair Geometry.
... View more
08-24-2015
07:07 AM
|
0
|
0
|
3155
|
|
POST
|
I am running ArcGIS 10.3.1.4959. I downloaded gdal18.dll from GitHub. Both my installed copy and the GitHub copy say version 1.8.0.10300, but my installed copy is 7.87 MB and the GitHub copy is 9.48 MB. Although the names and file versions are the same, obviously the files aren't the same. I will move the GitHub copy over to \bin and test it shortly. Regarding the Whitehorse GeoPackage, what table, data element, etc... are you using to determine an invalid spatial reference. The gpkg_spatial_ref_sys table does list undefined Cartesian and Geographic coordinate reference systems, but it also lists WGS84 and Web Mercator. The gpkg_contents and gpkg_tile_matrix_set tables state Web Mercator as the SRS ID. UPDATE: Tried the GitHub gdal18.dll, same error: 000582. Something else I noticed, 150+ ~10KB SQLite files were created in my %TEMP% folder. Does this seem right? Are they supposed to be cleaned up at some time or will my %TEMP% folder be filled with these files?
... View more
08-21-2015
03:08 PM
|
0
|
0
|
3900
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | a week ago | |
| 2 | 3 weeks ago | |
| 1 | 3 weeks ago | |
| 2 | 06-05-2026 10:30 AM | |
| 1 | 05-29-2026 08:22 AM |
| Online Status |
Online
|
| Date Last Visited |
Thursday
|