|
BLOG
|
I agree. I had some thoughts in my head on this subject, and your blog post was the nudge I needed to get them written down. Whether a bug or design failure, I think something is remiss with the ArcPy Geometry Classes when it comes to constructing geometries. If Esri wants to claim that Point is not a geometry class so it can't support an empty point, fine, but then arcpy.Point() and arcpy.Point(None) should throw exceptions instead of returning POINT (0 0). Additionally, PointGeometry should support calling with no arguments or a None argument to generate an empty point instead of throwing exceptions the way it does now. Just for fun, it is interesting to see how Shapely handles this situation: >>> from shapely.geometry import Point
>>> point_empty = Point()
>>> type(point_empty)
<class 'shapely.geometry.point.Point'>
>>> point_empty.wkt
'GEOMETRYCOLLECTION EMPTY' With Shapely, the Point object is actually a geometry class, unlike with ArcPy. Also, calling Point with no arguments returns an empty point as an empty geometry collection.
... View more
04-18-2015
12:02 PM
|
0
|
0
|
1173
|
|
BLOG
|
I don't mean to get hung up on semantics, but I usually can't help myself. Are you interested in a null point or empty point? Without getting into the debate of whether Python has a null or not, isn't the Python equivalent of a null anything None? Even when a company like Esri, Microsoft, Oracle, or [insert open source product here] says they are implementing the OGC Simple Feature standards (Simple Feature Access - Part 1: Common Architecture, Simple Feature Access - Part 2: SQL Option, etc...), I have come to expect idiosyncrasies when it comes to how those standards are implemented or translate to a company's geometry data type. When it comes to Esri, specifically ArcPy, it took me a while to figure out that they do in fact implement an empty point or POINT EMPTY. My initial confusion came from not appreciating what I was reading in Esri's documentation: Point -- Help | ArcGIS for Desktop. Discussion A Point is not a geometry class, but is commonly used to construct geometry. In the example below, a Point is used to create a PointGeometry object. It is a bit odd that Esri puts the Point documentation in with the geometry classes, but the documentation itself does clearly state that a Point is not a geometry class. Typing the objects in Python does affirm what the documentation states: >>> point = arcpy.Point()
>>> type(point)
<class 'arcpy.arcobjects.arcobjects.Point'>
>>> pointGeometry = arcpy.PointGeometry(point)
>>> type(pointGeometry)
<class 'arcpy.arcobjects.geometries.PointGeometry'> It is at this point that I have to start assuming what Esri was thinking because I have yet to find any documentation that explains the following. Since Point is not a geometry class, it cannot implement an empty point, or at least it doesn't. Instead, an empty point is implemented in PointGeometry. Where things are really awkward is that PointGeometry as a point geometry constructor requires either Point or Array objects. If Point can't construct an empty point, how does one go about making PointGeometry construct an empty point? Maybe pass an empty Array object or an Array object with a None object? >>> point
<Point (0.0, 0.0, #, #)>
>>> pointGeometry.WKT
u'POINT (0 0)'
>>> pointGeometry = arcpy.PointGeometry(arcpy.Array())
Runtime error
Traceback (most recent call last):
....
RuntimeError: Object: CreateObject cannot create geometry from inputs
>>> pointGeometry = arcpy.PointGeometry(arcpy.Array(None))
Runtime error
Traceback (most recent call last):
....
RuntimeError: Object: CreateObject cannot create geometry from inputs Nope, that doesn't work. Fortunately, there are other geometry constructors. My preference is to use arcpy.FromWKT (FromWKT -- Help | ArcGIS for Desktop). >>> pointGeometry = arcpy.FromWKT('POINT EMPTY')
>>> pointGeometry.WKT
u'POINT EMPTY'
>>> pointGeometry.JSON
u'{"x":"NaN","y":"NaN","spatialReference":{"wkid":null}}'
>>> repr(pointGeometry.firstPoint)
'None' If the Point associated with an empty point is really of NoneType instead of arcpy.arcobjects.arcobjects.Point, can we pass a None object to PointGeometry to create an empty point? >>> arcpy.PointGeometry(None)
Runtime error
Traceback (most recent call last):
....
RuntimeError: Object: CreateObject cannot create geometry from inputs Again, no. The question now, or at least when I first reached this point, is whether ArcGIS and ArcPy actually implement an empty point or whether the empty point from using arcpy.FromWKT just looks like an empty point. I can't say I have done exhausting testing, but a few cursory checks indicate it isn't just appearances. >>> point_empty = arcpy.FromWKT('POINT EMPTY')
>>> point_empty.WKT
u'POINT EMPTY'
>>> point = arcpy.FromWKT('POINT (1 1)')
>>> point.WKT
u'POINT (1 1)'
>>> #Check that union of point with empty point is point
>>> point.union(point_empty).WKT
u'MULTIPOINT ((1 1))'
>>> #Check that intersect of point with empty point is empty point
>>> point.intersect(point_empty, 1).WKT
u'POINT EMPTY'
>>> #Check that point contains empty point
>>> point.contains(point_empty)
True
>>> #Check that point is disjoint from empty point
>>> point.disjoint(point_empty)
True In the end, it seems ArcGIS and ArcPy implement an empty point, but the ArcPy Geometry Classes fail as constructors to support it.
... View more
04-18-2015
10:20 AM
|
0
|
0
|
1173
|
|
POST
|
So running the script you posted is noticeably slower than doing it manually? Creating the versions is quicker if you do it one by one manually?
... View more
04-17-2015
09:40 AM
|
0
|
1
|
4642
|
|
POST
|
You had this exact workflow working on this exact machine using an earlier version? What version?
... View more
04-17-2015
09:38 AM
|
0
|
1
|
4166
|
|
POST
|
Shaun Walbridge, good news, indeed. With Pro having its own numbering/versioning scheme, separate from ArcGIS Desktop, it gets a bit confusing in terms of what will be released when. Outside of ArcGIS 10.3.1 being released shortly, is release information for ArcGIS Desktop 10.3.2, ArcGIS 10.4, and ArcGIS Pro 1.1 publicly documented anywhere?
... View more
04-16-2015
06:48 PM
|
0
|
1
|
4633
|
|
POST
|
Recent questions/discussions on GeoNet got me thinking about an ArcPy Data Access module limitation I hadn't thought about in a while, specifically the lack of date and time support when working with NumPy arrays. Given where date and time support in NumPy was in 2012 when Esri introduced the ArcPy Data Access module, I can understand why support was missing then, but I think the time is right for them to start supporting it. I went ahead and created the suggestion on the ArcGIS Ideas site: ArcPy Data Access Support for numpy.datetime64 and Python datetime. I also logged an enhancement request with Esri Support: ENH-000086993: Update the ArcPy Data Access module to include support for numpy.datetime64 and Python datetime. If you would like to see date and time support for the NumPy-related methods in the ArcPy Data Access module, I encourage you to go promote the idea on ArcGIS Ideas and submit your own use case to Esri Support to have your customer number attached the aforementioned enhancement request.
... View more
04-16-2015
02:44 PM
|
1
|
11
|
9153
|
|
POST
|
Interesting, I guess I never noticed. Now the lack of datetime support with ArcGIS and NumPy hurts even more.
... View more
04-15-2015
01:59 PM
|
1
|
0
|
1677
|
|
POST
|
Typically, I use an SDE connection file to a regular/nonSDE database for simplicity's sake, but the connection can be created on the fly. Here is a generalized example for SQL Server Express: sde_conn = arcpy.ArcSDESQLExecute(instance="sde:sqlserver:host\MSSQLExpress", database="DB") The above will use Operating System Authentication since I am connecting to SQL Server and not specifying a username/password. The syntax for creating on-the-fly connections using ArcSDESQLExecute is the same as the direct connect syntax prior to ArcGIS 10.1 when they started changing connections to databases.
... View more
04-15-2015
11:57 AM
|
2
|
0
|
1677
|
|
POST
|
One can use SDE connection files, and ArcSDESQLExecute, against databases that are not registered SDE databases, at least I do it with SQL Server regularly and assume it would work with Oracle as well.
... View more
04-15-2015
08:42 AM
|
2
|
3
|
1677
|
|
POST
|
Have you read the Executing SQL using an ArcSDE connection documentation? I have used the ArcSDESQLExecute object in the past to accomplish similar tasks as what you are trying here.
... View more
04-15-2015
07:51 AM
|
3
|
8
|
4174
|
|
POST
|
I meant to include the following in my original reply but had to step away. You can see what I am talking about by using three different ways to create an ArcPy Polygon and then return the WKT for all three: >>> polys = [
... arcpy.FromWKT("POLYGON((0 0, 1 0, 1 1, 0 1, 0 0))"),
... arcpy.FromWKT("MULTIPOLYGON(((0 0, 1 0, 1 1, 0 1, 0 0)))"),
... arcpy.Polygon(
... arcpy.Array([
... arcpy.Point(0, 0),
... arcpy.Point(1, 0),
... arcpy.Point(1, 1),
... arcpy.Point(0, 1),
... arcpy.Point(0, 0)
... ])
... )
... ]
...
>>> for poly in polys:
... print poly.WKT
...
MULTIPOLYGON (((0 0, 1 0, 1 1, 0 1, 0 0)))
MULTIPOLYGON (((0 0, 1 0, 1 1, 0 1, 0 0)))
MULTIPOLYGON (((1.0001220703125 0, 1.0001220703125 1.0001220703125, 0 1.0001220703125, 0 0, 1.0001220703125 0)))
... View more
04-14-2015
06:08 PM
|
1
|
0
|
2428
|
|
POST
|
This is one of those lost in translation moments. Esri doesn't implement a Polygon and Multipolygon, they implement a "Polygon" that is a Multipolygon. Esri's polygon can be single or multipart, but they treat them both the same for translating to OGC's WKT.
... View more
04-14-2015
02:51 PM
|
1
|
0
|
2428
|
|
POST
|
What version of ArcGIS are you using? I ask because there were some changes, I would argue bugs, with how serviceProperties behave differently in ArcGIS 10.3 than ArcGIS 10.2.2. Not sure if that could affect isServiceLayer as well or not.
... View more
04-13-2015
03:17 PM
|
1
|
1
|
1221
|
|
POST
|
+1, automation is the way to go with tasks like this one.
... View more
04-13-2015
01:02 PM
|
1
|
0
|
1486
|
|
POST
|
Have you reviewed the Understanding how to use Microsoft Excel files in ArcGIS section of the Help, particularly the "few things to keep in mind" items? Is this an XLS or XLSX file? What version of MS Office do you have installed?
... View more
04-13-2015
12:58 PM
|
0
|
0
|
692
|
| 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
|