Clipping Polyline from Polygon - Geometry

519
4
Jump to solution
03-24-2023 07:12 AM
vtey_esriau
New Contributor III

 

Hi, I am trying to find the length of polyline in a polygon however clip only accepts envelop (rectangle). what can I do to get the total length of the polyline within a polygon. Thanks in advance.

for track_f in track_fset.features:
        track_polyline = Polyline(track_f.geometry)
        clipped_track_polyline = track_polyline.clip(Polygon(bounding_geom))
        print(type(clipped_track_polyline))

 

vtey_esriau_0-1679666826199.png

 

0 Kudos
1 Solution

Accepted Solutions
DavidPike
MVP Frequent Contributor

ah glad it may work, I've no experience of doing it however. The documentation also seems a bit arcane.

I'm assuming it's returning a set of points where they intersect?

the doc here suggest a 'dimension' parameter https://developers.arcgis.com/python/guide/part3-spatial-operations-on-geometries/

so perhaps:

 

yourGeometry.intersect(yourOtherGeom, dimension=2)

 

 

 

a4. intersect() V.S. overlaps()

The intersect() constructs a geometry that is the geometric intersection of the two input geometries. Different dimension values can be used to create different shape types. The intersection of two geometries of the same shape type is a geometry containing only the regions of overlap between the original geometries, and its arguments include:

  • second_geometry: required arcgis.geometry.Geometry.
  • A second geometry dimension: required Integer. The topological dimension (shape type) of the resulting geometry, which can be:
    • 1: A zero-dimensional geometry (point or multipoint).
    • 2: A one-dimensional geometry (polyline).
    • 4: A two-dimensional geometry (polygon).

 

View solution in original post

0 Kudos
4 Replies
DavidPike
MVP Frequent Contributor

try intersect()

0 Kudos
vtey_esriau
New Contributor III

wow, thanks @DavidPike . I simply assumed intersect returns True or False :D. I tested with intersect and it is returning a multipoint. Any advise on how to convert that to a polyline?

 

0 Kudos
DavidPike
MVP Frequent Contributor

ah glad it may work, I've no experience of doing it however. The documentation also seems a bit arcane.

I'm assuming it's returning a set of points where they intersect?

the doc here suggest a 'dimension' parameter https://developers.arcgis.com/python/guide/part3-spatial-operations-on-geometries/

so perhaps:

 

yourGeometry.intersect(yourOtherGeom, dimension=2)

 

 

 

a4. intersect() V.S. overlaps()

The intersect() constructs a geometry that is the geometric intersection of the two input geometries. Different dimension values can be used to create different shape types. The intersection of two geometries of the same shape type is a geometry containing only the regions of overlap between the original geometries, and its arguments include:

  • second_geometry: required arcgis.geometry.Geometry.
  • A second geometry dimension: required Integer. The topological dimension (shape type) of the resulting geometry, which can be:
    • 1: A zero-dimensional geometry (point or multipoint).
    • 2: A one-dimensional geometry (polyline).
    • 4: A two-dimensional geometry (polygon).

 

0 Kudos
vtey_esriau
New Contributor III

thank you 🙂 that worked. I should really learn to read the documentation.

I was reading - https://developers.arcgis.com/python/api-reference/arcgis.geometry.html#intersect

 

 

0 Kudos