本文整理汇总了Python中arcpy.Polygon方法的典型用法代码示例。如果您正苦于以下问题:Python arcpy.Polygon方法的具体用法?Python arcpy.Polygon怎么用?Python arcpy.Polygon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类arcpy
的用法示例。
在下文中一共展示了arcpy.Polygon方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_cls_boundary
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Polygon [as 别名]
def generate_cls_boundary(cls_input,cntr_id_field,boundary_output,cpu_core):
arcpy.env.parallelProcessingFactor=cpu_core
arcpy.SetProgressorLabel('Generating Delaunay Triangle...')
arrays=arcpy.da.FeatureClassToNumPyArray(cls_input,['SHAPE@XY',cntr_id_field])
cid_field_type=[f.type for f in arcpy.Describe(cls_input).fields if f.name==cntr_id_field][0]
delaunay=Delaunay(arrays['SHAPE@XY']).simplices.copy()
arcpy.CreateFeatureclass_management('in_memory','boundary_temp','POLYGON',spatial_reference=arcpy.Describe(cls_input).spatialReference)
fc=r'in_memory\boundary_temp'
arcpy.AddField_management(fc,cntr_id_field,cid_field_type)
cursor = arcpy.da.InsertCursor(fc, [cntr_id_field,"SHAPE@"])
arcpy.SetProgressor("step", "Copying Delaunay Triangle to Temp Layer...",0, delaunay.shape[0], 1)
for tri in delaunay:
arcpy.SetProgressorPosition()
cid=arrays[cntr_id_field][tri[0]]
if cid == arrays[cntr_id_field][tri[1]] and cid == arrays[cntr_id_field][tri[2]]:
cursor.insertRow([cid,arcpy.Polygon(arcpy.Array([arcpy.Point(*arrays['SHAPE@XY'][i]) for i in tri]))])
arcpy.SetProgressor('default','Merging Delaunay Triangle...')
if '64 bit' in sys.version:
arcpy.PairwiseDissolve_analysis(fc,boundary_output,cntr_id_field)
else:
arcpy.Dissolve_management(fc,boundary_output,cntr_id_field)
arcpy.Delete_management(fc)
return
示例2: make_poly_from_extent
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Polygon [as 别名]
def make_poly_from_extent(ext, sr):
"""Make an arcpy polygon object from an input extent object.,Returns
a polygon geometry object.
Required:
ext -- extent object
sr -- spatial reference
Example
>>> ext = arcpy.Describe(fc).extent
>>> sr = 4326 #WKID for WGS 84
>>> poly = make_poly_from_extent(ext, sr)
>>> arcpy.CopyFeatures_management(poly, r'C:\Temp\Project_boundary.shp')
"""
array = arcpy.Array()
array.add(ext.lowerLeft)
array.add(ext.lowerRight)
array.add(ext.upperRight)
array.add(ext.upperLeft)
array.add(ext.lowerLeft)
return arcpy.Polygon(array, sr)
示例3: geometry
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Polygon [as 别名]
def geometry(self, geometry):
""" sets the geometry value """
if isinstance(geometry, AbstractGeometry):
self._geomObject = geometry
self._geomType = geometry.type
elif arcpyFound :
wkid = None
wkt = None
if (hasattr(geometry, 'spatialReference') and \
geometry.spatialReference is not None):
if (hasattr(geometry.spatialReference, 'factoryCode') and \
geometry.spatialReference.factoryCode is not None):
wkid = geometry.spatialReference.factoryCode
else:
wkt = geometry.spatialReference.exportToString()
if isinstance(geometry, arcpy.Polygon):
self._geomObject = Polygon(geometry, wkid=wkid, wkt=wkt)
self._geomType = "esriGeometryPolygon"
elif isinstance(geometry, arcpy.Point):
self._geomObject = Point(geometry, wkid=wkid, wkt=wkt)
self._geomType = "esriGeometryPoint"
elif isinstance(geometry, arcpy.Polyline):
self._geomObject = Polyline(geometry, wkid=wkid, wkt=wkt)
self._geomType = "esriGeometryPolyline"
elif isinstance(geometry, arcpy.Multipoint):
self._geomObject = MultiPoint(geometry, wkid=wkid, wkt=wkt)
self._geomType = "esriGeometryMultipoint"
else:
raise AttributeError("geometry must be a common.Geometry or arcpy.Geometry type.")
else:
raise AttributeError("geometry must be a common.Geometry or arcpy.Geometry type.")
#----------------------------------------------------------------------
示例4: __geomToPointList
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Polygon [as 别名]
def __geomToPointList(self, geom):
""" converts a geometry object to a common.Geometry object """
sr = geom.spatialReference
wkid = None
wkt = None
if sr is None:
if self._wkid is None and self._wkt is not None:
wkt = self._wkt
else:
wkid = self._wkid
else:
wkid = sr.factoryCode
g = json.loads(geom.JSON)
top = []
for gring in g['rings']:
ring = []
for g in gring:
ring.append(Point(coord=g, wkid=wkid, wkt=wkt, z=None, m=None))
top.append(ring)
return top
#if isinstance(geom, arcpy.Polygon):
#feature_geom = []
#fPart = []
#for part in geom:
#fPart = []
#for pnt in part:
#if geom.spatialReference is None:
#wkid = self._wkid
#else:
#wkid = geom.spatialReference.factoryCode
#fPart.append(Point(coord=[pnt.X, pnt.Y],
#wkid=wkid,
#z=pnt.Z, m=pnt.M))
#feature_geom.append(fPart)
#return feature_geom
#----------------------------------------------------------------------
示例5: asArcPyObject
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Polygon [as 别名]
def asArcPyObject(self):
""" returns the Envelope as an ESRI arcpy.Polygon object """
env = self.asDictionary
ring = [[
Point(env['xmin'], env['ymin'], self._wkid),
Point(env['xmax'], env['ymin'], self._wkid),
Point(env['xmax'], env['ymax'], self._wkid),
Point(env['xmin'], env['ymax'], self._wkid)
]]
return Polygon(rings=ring,
wkid=self._wkid,
wkt=self._wkid,
hasZ=False,
hasM=False).asArcPyObject
示例6: execute
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Polygon [as 别名]
def execute(in_datasets, out_fc):
# use gcs as output sr since all extents will fit in it
out_sr = arcpy.SpatialReference("WGS 1984")
in_datasets = in_datasets.split(";")
arcpy.CreateFeatureclass_management(os.path.dirname(out_fc),
os.path.basename(out_fc),
"POLYGON",
spatial_reference=out_sr)
arcpy.AddField_management(out_fc, "dataset", "TEXT", 400)
# add each dataset's extent & the dataset's name to the output
with arcpy.da.InsertCursor(out_fc, ("SHAPE@", "dataset")) as cur:
for i in in_datasets:
d = arcpy.Describe(i)
ex = d.Extent
pts = arcpy.Array([arcpy.Point(ex.XMin, ex.YMin),
arcpy.Point(ex.XMin, ex.YMax),
arcpy.Point(ex.XMax, ex.YMax),
arcpy.Point(ex.XMax, ex.YMin),
arcpy.Point(ex.XMin, ex.YMin),])
geom = arcpy.Polygon(pts, d.SpatialReference)
if d.SpatialReference != out_sr:
geom = geom.projectAs(out_sr)
cur.insertRow([geom, d.CatalogPath])
示例7: asShape
# 需要导入模块: import arcpy [as 别名]
# 或者: from arcpy import Polygon [as 别名]
def asShape(self):
"""Returns JSON as arcpy.Geometry() object."""
if self.geometryType != ESRI_ENVELOPE:
return arcpy.AsShape(self.json, True)
else:
ar = arcpy.Array([
arcpy.Point(self.json[XMIN], self.json[YMAX]),
arcpy.Point(self.json[XMAX], self.json[YMAX]),
arcpy.Point(self.json[XMAX], self.json[YMIN]),
arcpy.Point(self.json[XMIN], self.json[YMIN])
])
return arcpy.Polygon(ar, arcpy.SpatialReference(self.spatialReference))