|
POST
|
If you have the C:\Python27\ArcGISx6410.2 directory on your machine, then you installed 64-bit Background Geoprocessing (not part of the standard installation) or ArcGIS for Server. Assuming the latter isn't the case, the former is what put the extra Python interpreter installation on your machine. With regard to the OP's situation, 64-bit Background Geooprocessing wasn't introduced until ArcGIS 10.1 SP1. That said, the information provided is useful for others that install 64-bit Background Geoprocessing and get confused over which Python interpreter they are using when.
... View more
03-13-2015
07:12 AM
|
2
|
1
|
1131
|
|
POST
|
FeatureClassToNumpyArray, nah, that would be too easy. I got tunnel vision on showing the mechanics of building the numpy array, but FeatureClassToNumPyArray is the more ArcPy approach.
... View more
03-13-2015
07:04 AM
|
2
|
1
|
7114
|
|
POST
|
fc = #feature class with NEAR_X and NEAR_Y fields
idfield = #an identifier field
nearList = []
with arcpy.da.SearchCursor(fc, [idfield, "NEAR_X", "NEAR_Y"]) as cur:
for id, x, y in cur:
nearList.append((id, (x, y)))
dtype = numpy.dtype([(idfield,numpy.int32),('XY', '<f8', 2)])
narr = numpy.array(nearList, dtype) You can add extra fields, or drop the idfield, if you want.
... View more
03-12-2015
01:17 PM
|
1
|
4
|
7114
|
|
POST
|
I am using ArcGIS 10.3, and it isn't fixed! There is a bug with the arcpy.SelectLayerByLocation_management tool. At first I thought it might be related to using shape files, but I can generate the same issues with file geodatabases and even ArcSDE databases. The following code demonstrates how arcpy.SelectLayerByLocation_management misses the polygon while looping through a search cursor and checking for intersection gets the polygon. >>> arcpy.SelectLayerByLocation_management("xxxx_feat", "INTERSECT","xxxx_ext1", "", "NEW_SELECTION")
<Result 'xxxx_feat'>
>>> arcpy.GetCount_management("xxxx_feat")
<Result '1357'>
>>> arcpy.SelectLayerByAttribute_management("xxxx_feat","CLEAR_SELECTION")
<Result 'xxxx_feat'>
>>>
>>> i = 0
>>> ext = next(arcpy.da.SearchCursor("xxxx_ext1","SHAPE@"))[0]
>>> with arcpy.da.SearchCursor("xxxx_feat","SHAPE@") as cur:
... for shape, in cur:
... if not shape.disjoint(ext):
... i += 1
...
>>> i
1358
>>> The code above does raise the possibility of another approach. If you are always selecting from the same set of features, you could build a search cursor and loop over the same cursor each time the extent object changes. There are a couple of pluses with this approach. One, creating a new cursor takes more resources than simply resetting one. Two, the .disjoint method is quite quick.
... View more
03-11-2015
12:34 PM
|
1
|
2
|
5753
|
|
POST
|
This question was originally cross posted to StackExchange, where it received feedback, some of which was marked best answer. Geographic Information Systems Stack Exchange > How to get a search cursor on a particular version in arcpy
... View more
03-11-2015
08:49 AM
|
1
|
0
|
829
|
|
POST
|
Thanks for uploading data, it helps. If I use your data as-is, and choose Intersect_3D instead of Intersect, the polygon in question gets selected for a total of 1358. If I project your data from WGS84 to a North American continental projection like Lamberts Conformal Conic, I get the same result. Since using the 3D intersect option and projecting your data explicitly gets the same, expected result; I can only surmise something is going on with default values or tolerances when using geographic coordinates and a 2D intersect. Maybe the projection-on-the-fly is having an issue, I am not sure.
... View more
03-10-2015
11:14 AM
|
0
|
4
|
2000
|
|
POST
|
If I understand you correctly, it is one polygon on or near the periphery that is not being handled the way you think. A few questions. Is the missing polygon a single-part or multi-part polygon? You appear to be working at continental map scale, i.e., 1:60,000,000. What spatial reference are you using? Which part specifically isn't working? Does the arcpy.SelectLayerByLocation_management tool miss the polygon or does that step work and it is the search cursor that is missing it? Regarding cursors, you should really consider using the newer ArcPy Data Access (arcpy.da) cursors instead of the older/original ArcPy (arcpy) cursors.
... View more
03-09-2015
06:14 PM
|
0
|
8
|
3755
|
|
POST
|
Regarding spatial reference, yes, it is always a good idea to specify a spatial reference when creating ArcPy geometry objects. There are numerous, known precision issues that crop up with ArcPy geometry objects when spatial references aren't specified. Is lack of a spatial reference the issue here? We will know soon enough when you test it. When you are talking about a "shared point with the extent rectangle," I am a bit uncertain whether that is what you mean. "Shared point" could be taken to mean something very specific, like a polygon in question must share a vertex with the extent rectangle. Try adding the spatial reference, and then report back. Also, are the differences you are finding only along the periphery of the extent object? Are any polygons more in the interior being handled different. There are 15+ different types of overlaps one can specify. I picked Intersect in this case because it is the default and most common. It could be the CopyFeatures_management tool uses a different overlap type, or it could be a bug in one tool or the other.
... View more
03-09-2015
04:28 PM
|
0
|
10
|
3755
|
|
POST
|
You make a good point, i.e., each IDE handles things a bit different so some parts of my statements might not apply to others using different IDEs. That said, most of what I say is generally enough to apply on some level to most IDEs. Regarding the "import arcpy" question, it is an apples to oranges issue, or at least Granny Smith to Honeycrisp. An IDE code editor can't do name completion on a Python site package/library/module/etc... that isn't imported. The import statement is used by the code editor to expand code completion beyond the default or base Python packages, but that normally doesn't provide access to dynamic properties like ArcPy environment settings. In PyScripter when you add a package like ArcPy to the code completion special packages, it actually executes code to see all the run-time items you see in the interactive console and then caches them for use in the code editor. It isn't "seeing" those items like normal items, it had to execute code to find the items and then build a cache of them; hence, why you have to put arcpy in the special packages list to see them all. With PyCharm, there is a "Collect run-time types information for code insight" option that will build similar caches. With ArcPy, however, that feature doesn't seem to work very well. Whether the problem lies in Esri, JeBrains, or both I do not know.
... View more
03-09-2015
01:47 PM
|
1
|
1
|
4616
|
|
POST
|
arcpy.env.workspace is not a Python special method, it is an ArcPy environment setting exposed as a property on ArcPy's env class. When ArcPy is instantiated, the environment settings get defined and stored as a set in one of the environment object's internal or private attributes, _environments to be specific. You can use the Python dir() built-in function to see those environment settings, but you also see lots of other class attributes as well. The following code snippet shows only the environment settings: import arcpy
for env in arcpy.env._environments:
print env The interactive console is retrieving those environment settings and making them available for code completion to the user. The set of environment settings doesn't exist until an instance of ArcPy is created, so a user doesn't see them for code completion in the editor window. I can't say I am doing complete justice with this explanation, but I find it hard to get much more in depth without getting into the weeds of Python class structure and how properties are defined and managed. I think Esri would argue one should use the online documentation to understand ArcPy and not rely on code completion in a code editor or interactive window. Is Esri's implementation of the ArcPy Env class frustrating because of how it impacts code completion in editor windows, I think so; but I also think this factor is low on the list when considering how to structure ArcPy.
... View more
03-09-2015
10:43 AM
|
2
|
3
|
4616
|
|
POST
|
I can give a partial answer now. I have to check a couple of things before giving the other part of my answer. Some of the difference is due to the interactive Python console hiding Python's dunder/magic/special methods from the user. Python special methods are used for managing namespaces and implementing Python's approach to operator overloading. Since the are "special," it is assumed the end user doesn't need to be interacting directly with them, so the interactive console doesn't list them. Note, what you see in the PyCharm interactive console differs from what you see in the ArcGIS Desktop interactive console. The PyCharm interactive console will show more of the special methods than the ArcGIS Desktop interactive console.
... View more
03-09-2015
09:15 AM
|
1
|
5
|
4616
|
|
POST
|
Use arcpy.SelectLayerByLocation_management first to create a selection on your feature layer, then create the search cursor. If you are using ArcGIS 10.3 and already have an extent object created, you can pass the extent object's polygon property to arcpy.SelectLayerByLocation_management. If you are using ArcGIS 10.2.2 or earlier, you can manually create a polygon using the extent object's bounds.
... View more
03-09-2015
07:36 AM
|
1
|
13
|
3755
|
|
POST
|
Do you have 64-bit Background Geoprocessing installed? Whether 64-bit Background Geoprocessing is installed, does enabling or disabling "Background Processing" in the geoprocessing options change anything?
... View more
03-05-2015
02:38 PM
|
0
|
1
|
1689
|
|
POST
|
Since ArcGIS Pro is an integrated 2D/3D application, it will be interesting to see if Esri extends the existing ArcPy Geometry classes or introduces new ones that support 3D differently.
... View more
03-05-2015
09:22 AM
|
0
|
0
|
3622
|
| Title | Kudos | Posted |
|---|---|---|
| 2 | a month ago | |
| 1 | 05-29-2026 08:22 AM | |
| 1 | 06-02-2026 06:16 AM | |
| 3 | 06-01-2026 01:55 PM | |
| 1 | 05-22-2026 05:27 AM |
| Online Status |
Offline
|
| Date Last Visited |
yesterday
|