Python ArcGIS Geometry

Source: Internet
Author: User
Tags polyline
Geometry

ArcGIS 10 Summary

Geometry objects define a spatial location and an associated geometric shape.

Discussion

In many geographic processing workflows, you may need to use coordinates and geometric information to run specific operations, but do not necessarily want to create a new (temporary) the process of using the element class, filling the element class with the cursor, and using the element class, and then deleting the temporary element class. You can use geometric objects to replace input and output to simplify geographic processing. You can use the geometry, multipoint, pointgeometry, polygon, or polyline class to create a geometric object from the beginning.

Syntax Geometry (geometry, inputs, {spatialreference}, {hasz}, {hasm })
Parameters Description Data Type
Geometry

The geometry type: Point, polygon, polyline, or multipoint.

String
Inputs

The coordinates used to create the object. The datatype can be either point or array objects.

Object
Spatialreference

The spatial reference of the new geometry.

(Default value: None)

Spatialreference
Hasz

The Z state: true for geometry if z is enabled and false if it is not.

(Default value: false)

Boolean
Hasm

The M state: true for geometry if M is enabled and false if it is not.

(Default value: false)

Boolean
Attribute
Attribute Description Data Type
Area

(Read-only)

The area of a polygon feature. Empty for all other feature types.

Double
Centroid

(Read-only)

The true centroid if it is within or on the feature; otherwise, the label point is returned. Returns a point object.

Point
Extent

(Read-only)

The extent of the geometry.

Extent
Firstpoint

(Read-only)

The first coordinate point of the geometry.

Point
Hullrectangle

(Read-only)

A space-delimited string of the coordinate pairs of the convex hull rectangle.

String
Ismultipart

(Read-only)

True, if the number of parts for this geometry is more than one.

Boolean
Labelpoint

(Read-only)

The point at which the label is located. The labelpoint is always located within or on a feature.

Point
Lastpoint

(Read-only)

The last coordinate of the feature.

Point
Length

(Read-only)

The length of the linear feature. Zero for point, multipoint feature types.

Double
Partcount

(Read-only)

The number of geometry parts for the feature.

Integer
Pointcount

(Read-only)

The total number of points for the feature.

Integer
Truecentroid

(Read-only)

The center of gravity for a feature.

Point
Type

(Read-only)

The geometry type: polygon, polyline, point, multipoint, multipatch, dimension, annotation.

String
Method Overview
Method Description
Contains (second_geometry)

Indicates if the base geometry contains the comparison geometry.

Contains is the opposite of.

Only true relationships are shown in this procedure.

Crosses (second_geometry)

Indicates if the two geometries intersect in a geometry of a lesser shape type.

Two polylines cross if they share only points in common, at least one of which is not an endpoint. A polyline and an polygon cross if they share a polyline or a point (for vertical line) in common on the interior of the polygon which is not equivalent to the entire polyline.

Only true relationships are shown in this procedure.

Disjoint (second_geometry)

Indicates if the base and comparison geometries share no points in common.

Two geometries Intersect if disjoint returns false.

Only true relationships are shown in this procedure.

Equals (second_geometry)

Indicates if the base and comparison geometries are of the same shape type and define the same set of points in the plane.

Only true relationships are shown in this procedure.

Getpart ({index })

Returns an array of point objects for a participant part of geometry or an array containing a number of arrays, one for each part.

Overlaps (second_geometry)

Indicates if the intersection of the two geometries has the same shape type as one of the input geometries and is not equivalent to either of the input geometries.

Only true relationships are shown in this procedure.

Touches (second_geometry)

Indicates if the boundaries of the geometries intersect.

Two geometries touch when the intersection of the geometries is not empty, but the intersection of their interiors is empty. for example, a point touches a polyline only if the point is coincident with one of the polyline end points.

Only true relationships are shown in this procedure.

Within (second_geometry)

Indicates if the base geometry is within the comparison geometry.

Within is the opposite operator of contains.

Only true relationships are shown in this procedure.

Method Contains (second_geometry)
Parameters Description Data Type
Second_geometry

A second geometry.

Object

Return Value

Data Type Description
Boolean

A return Boolean value of true indicates this geometry contains the second geometry.

Crosses (second_geometry)
Parameters Description Data Type
Second_geometry

A second geometry.

Object

Return Value

Data Type Description
Boolean

A return Boolean value of true indicates the two geometries intersect in a geometry of a lesser shape type.

Disjoint (second_geometry)
Parameters Description Data Type
Second_geometry

A second geometry.

Object

Return Value

Data Type Description
Boolean

A return Boolean value of true indicates that the two geometries share no points in common.

Equals (second_geometry)
Parameters Description Data Type
Second_geometry

A second geometry.

Object

Return Value

Data Type Description
Boolean

A return Boolean value of true indicates that the two geometries are of the same shape type and define the same set of points in the plane.

Getpart ({index })
Parameters Description Data Type
Index

The index position of the geometry.

Integer

Return Value

Data Type Description
Array

Getpart returns an array of point objects for a participant part of the geometry if an index is specified. if an index is not specified, an array containing an array of point objects for each geometry part is returned.

Overlaps (second_geometry)
Parameters Description Data Type
Second_geometry

A second geometry.

Object

Return Value

Data Type Description
Boolean

A return Boolean value of true indicates the intersection of the two geometries has the same dimension as one of the input geometries.

Touches (second_geometry)
Parameters Description Data Type
Second_geometry

A second geometry.

Object

Return Value

Data Type Description
Boolean

A return Boolean value of true indicates the boundaries of the geometries intersect.

Within (second_geometry)
Parameters Description Data Type
Second_geometry

A second geometry.

Object

Return Value

Data Type Description
Boolean

A return Boolean value of true indicates this geometry is contained within the second geometry.

Code example geometry example

When you set the output parameter of a geoprocessing tool to a empty geometry object, the tool will return a list of geometry objects.

import arcpy# Create an empty Geometry object#g = arcpy.Geometry()# Run the CopyFeatures tool, setting the output to the geometry object.  GeometryList#  is returned as a list of geometry objects.#  geometryList = arcpy.CopyFeatures_management("c:/data/streets.shp", g)# Walk through each geometry, totalling the length#length = 0for geometry in geometryList:    length += geometry.lengthprint "Total length: %f" % length
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.