|
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
|
2088
|
|
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
|
3886
|
|
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
|
3886
|
|
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
|
4766
|
|
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
|
4766
|
|
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
|
4766
|
|
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
|
3886
|
|
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
|
1743
|
|
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
|
3779
|
|
POST
|
Overall, I think the ArcPy support for Z and M coordinates is poor, quite poor. I wish I had a better response, but I just hit walls/bugs/design limitations around every corner. I quickly revisited arcpy.AsShape and arcpy.FromWKT. Although the Help for FromWKT doesn't state anything one way or another about Z or M coordinates, the function throws an error when you try to use Z or M coordinates. I have been able to use arcpy.ArcSDESQLExecute to pass Z and M WKT coordinates to SQL Server Express, basically bypass ArcPy and relying on the SQL Server engine to handle creating the shapes correctly. Even though it has worked for me, and I can view the results in ArcMap, all of the regular and Data Access cursors seem to do nothing with them. It might just be ArcPy cursors can't cope with Z or M coordinates, need to investigate more. Good luck, let us know if you have any success. UPDATE: I had to strike through some of my earlier comments. On the WKT comment, it is still the case that the Help doesn't explicitly mention Z or M coordinates; however, arcpy.FromWKT was throwing an error because I wasn't giving it OGC compliant WKT representations. I am used to MS SQL Server's WKT implementation, which is slightly different than the OGC specifications, so what I would pass SQL Server was failing with ArcPy. On the ArcPy cursors not working with ZM polygons created through SQL Server and arcpy.ArcSDESQLExecute, I had a goofy projection discrepancy that was causing the problems. Once I went back and straightened out the projections, I was able to use cursors with the newly created polygons.
... View more
03-04-2015
12:07 PM
|
2
|
2
|
3779
|
|
POST
|
I agree that Python object equivalence/equality likely isn't the best approach for comparing spatial objects primarily because I haven't seen any geospatial Python packages where the various geometry classes' __eq__() methods are spatially aware. With ArcPy, they are not. >>> pl1 = arcpy.Polyline(
... arcpy.Array(
... [arcpy.Point(0, 0), arcpy.Point(1, 1)]
... )
... )
...
>>> pl2 = arcpy.Polyline(
... arcpy.Array(
... [arcpy.Point(0, 0), arcpy.Point(0.5, 0.5), arcpy.Point(1, 1)]
... )
... )
...
>>> pl1 == pl2
False
>>> pl1.equals(pl2)
True For points, Python object equality works in some situations because of how simple points are spatially. Once we move into polylines and polygons, and possibly multipoints, using Python object equality falls short.
... View more
03-03-2015
03:31 PM
|
0
|
0
|
3779
|
|
POST
|
How ArcPy is handling methods for testing spatial relations between geometric objects, e.g., equals, is consistent with the OGC Simple Feature Access - Part 1: Common Architecture use of Z and M coordinate values: 6.1.2.5 Use of Z and M coordinate values A Point value may include a z coordinate value.... A Point value may include an m coordinate value.... Observer methods returning Point values include z and m coordinate values when they are present. Spatial operations work in the "map geometry" of the data and will therefore not reflect z or m values in calculations (e.g., Equals, Length) or in generation of new geometry values (e.g., Buffer, ConvexHull, Intersection). This is done by projecting the geometric objects onto the horizontal plane to obtain a "footprint" or "shadow" of the objects for the purposed of map calculations. In other words, it is possible to store and obtain z (and m) coordinate values but they are ignored in all other operations which are based on map geometries. Implementations are free to include true 3D geometric operations, but should be consistent with ISO 19107. The operative statement for this discussion is really the last one, i.e., implementations are free to include true 3D [or 4D] geometric operations, but I will circle back to this in a minute. Other products that implement the OGC Simple Feature Access standards behave the same way as ArcPy in this instance. Looking at Shapely, which is based on GEOS and JTS libraries, and grabbing a few example points from the original code snippets: >>> from shapely.geometry import Point
>>> a = Point(1, 2, 3)
>>> print a
POINT Z (1 2 3)
>>> c = Point(1, 2, 0)
>>> print c
POINT Z (1 2 0)
>>> a == c
False
>>> a.equals(c)
True Even looking at how MS SQL Server implements its Geometry data type: >>>Declare @a geometry, @c geometry
>>>SET @a = 'POINT(1 2 3 4)'
>>>PRINT @a.ToString()
POINT (1 2 3 4)
>>>SET @c = 'POINT(1 2 0 0)'
>>>PRINT @c.ToString()
POINT (1 2 0 0)
>>>PRINT @a.STEquals(@c)
1 I think the behavior being seen in ArcPy is typical, some might even argue expected given the Simple Feature specifications/standards. That said, Esri could implement OGC Feature Geometry/ ISO 19107 Geographic information -- Spatial schema in ArcPy, but even that would not necessarily address all of the issues here because Esri has created a 5D point model (x, Y, Z, M, ID). Has Esri failed or dropped the ball on this one? It could be argued, but their existing implementation could also be defended on some levels. The Simple Features specification sets the bar pretty low, but Esri also hasn't tried to raise it for themselves. There is nothing in the specifications that prevents them from adding more robust functionality. Think of how Microsoft handled the situation, i.e., they have OGC methods and Extended methods so they can remain compliant but add extra functionality.
... View more
03-03-2015
02:36 PM
|
1
|
4
|
3779
|
|
POST
|
In terms of null points, I completely agree with you that arcpy.Point() should not return the <Point (0.0, 0.0, #, #)> that it does. I think Shapely/GEOS/JTS handles the situation much better: >>> from shapely.geometry import Point
>>> null_pnt = Point()
>>> print null_pnt
GEOMETRYCOLLECTION EMPTY With an empty geometry collection, comparing a null/empty point to a valid regular point with 0, 0 coordinates behaves the way one would suspect: >>> real_pnt = Point(0, 0, 1)
>>> print real_pnt
POINT Z (0 0 1)
>>> null_pnt.equals(real_pnt)
False I think an empty geometry collection is the way to go; unfortunately, Esri hasn't implemented a geometry collection type with ArcPy. Off the top, four different ideas come to mind how to handle the situation without a geometry collection: have arcpy.Point() throw an error saying the coordinates aren't valid implement an empty point concept and return an empty point return a None object return a valid point using the 0, 0 coordinates Out of the four options above, I think #4 (the existing condition) is the least desirable from a user/developer perspective.
... View more
03-03-2015
08:50 AM
|
1
|
0
|
3779
|
|
POST
|
I see you made progress with Xander Bakker's code, glad he was able to help and provide some additional learning links. Beyond what has already been said, I will just point out that Python functions with 15+ parameters are quite rare, even 10 is unusual. And, they are all required arguments! In cases like this, usually the code can benefit from being restructured. If all of these arguments have to be passed, maybe just building a list or dictionary and passing it as a single argument would make sense.
... View more
03-02-2015
11:03 AM
|
1
|
0
|
4516
|
| Title | Kudos | Posted |
|---|---|---|
| 1 | 06-11-2026 07:04 AM | |
| 1 | 07-17-2026 06:54 AM | |
| 2 | 07-06-2026 12:29 PM | |
| 1 | 07-06-2026 12:00 PM | |
| 2 | 06-05-2026 10:30 AM |
| Online Status |
Offline
|
| Date Last Visited |
Wednesday
|