writing wkt using arcpy.da

4316
3
Jump to solution
04-14-2015 01:26 PM
karenpayne
New Contributor

I've writing a python script that coverts data to WKT. It works fine except it seems to assume that all source polygon layers are multipolygons, even if they aren't.  The syntax is correct for multipolygon, but it seems that the data access module treats all shape@wkt commands and returns multipolygon even when the when the source data is a single polygon that doesn't participate in multipart geometry. Has anyone else noticed this?

0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

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 solution in original post

3 Replies
JoshuaBixby
MVP Esteemed Contributor

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.

karenpayne
New Contributor

Good to know - thanks Josh!

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

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)))