Select to view content in your preferred language

Is a polygon with a hole a multipart polygon?

7085
25
01-09-2018 10:47 AM
EidurEidsson
Emerging Contributor

Consider the following script, the polygon is a simple one with a hole inside:

import arcpy

poly1 = arcpy.FromWKT("POLYGON ((35 10, 45 45, 15 40, 10 20, 35 10), (20 30, 35 35, 30 20, 20 30))")

print(poly1.isMultipart)
print(poly1.partCount)‍‍‍‍‍‍

The result I get is

>>>
True
1

So is a polygon "multipart" if it has holes? ArcGIS Data Reviewer does not agree.

Thanks

ArcGIS Desktop 10.5.1

Tags (1)
25 Replies
XanderBakker
Esri Esteemed Contributor

Just wondering... how would you create a "PointGeometry with value of None"?

If I try:  

pntg = arcpy.PointGeometry()

or

pntg = arcpy.PointGeometry(None)

it will throw:

RuntimeError: Object: CreateObject cannot create geometry from inputs

If I provide a "Nominal Point" it will be valid:

pntg = arcpy.PointGeometry(arcpy.Point())
print pntg.firstPoint
# 0 0 NaN NaN

buf = pntg.buffer(1)
print buf.area
# 3.14159265359
0 Kudos
VinceAngelo
Esri Esteemed Contributor

You wouldn't. But if you query a table with null geometries, a None would be returned for the row's array element where the PointGeometry would result.

- V

JoshuaBixby
MVP Esteemed Contributor

My preference would be for an empty point:

>>> import arcpy
>>>
>>> # if I could wave a wand
>>> pt = arcpy.Point()
>>> pt.WKT
'POINT EMPTY'
DanPatterson_Retired
MVP Emeritus

It is possible though

a = np.array([np.nan, np.nan, np.nan, np.nan])

p = arcpy.Point()
<Point (0.0, 0.0, #, #)>

p.X, p.Y, p.Z, p.M = a

p
<Point (nan, nan, nan, nan)>
0 Kudos
DanPatterson_Retired
MVP Emeritus

I think you mean that is one of your ST point geometries 

pt = arcpy.Point()
pg = arcpy.PointGeometry(pt)
pg.WKT'POINT (0 0)'‍‍‍‍

# because

pt.WKT()
Traceback (most recent call last):

  File "<ipython-input-30-6f7eed26629f>", line 1, in <module>
    pt.WKT()

AttributeError: 'Point' object has no attribute 'WKT'
0 Kudos
JoshuaBixby
MVP Esteemed Contributor

You are right, I am interested in point geometry and not point.  What most of the world calls "point", Esri calls "point geometry" because Esri calls vertices points.

0 Kudos