misc.md

July 24, 2021 ยท View on GitHub

Misc Examples :

  • Line Intersect : Takes any LineString or Polygon GeoJSON and returns the intersecting point(s).
ArgumentTypeDescription
feature1FeatureAny LineString or Polygon, if one of the two features is polygon to improve performance please pass polygon as this parameter
feature2FeatureAny LineString or Polygon.
ReturnTypeDescription
pointsFeatureCollectionFeatureCollection of intersecting points
from geojson import LineString, Feature
from turfpy.misc import line_intersect
l1 = Feature(geometry=LineString([[126, -11], [129, -21]]))
l2 = Feature(geometry=LineString([[123, -18], [131, -14]]))
line_intersect(l1, l2)
  • Line Segment : Creates a FeatureCollection of 2-vertex LineString segments from a (Multi)LineString or (Multi)Polygon.
ArgumentTypeDescription
geojsonGeometry or Feature or FeatureCollectionGeoJSON Polygon or LineString
ReturnTypeDescription
segmentsFeatureCollectionFeatureCollection 2-vertex line segments
from turfpy.misc import line_segment

poly = {
      "type": "Feature",
      "properties": {},
      "geometry": {
        "type": "Polygon",
        "coordinates": [
          [
            [
              51.17431640625,
              47.025206001585396
            ],
            [
              45.17578125,
              43.13306116240612
            ],
            [
              54.5361328125,
              41.85319643776675
            ],
            [
              51.17431640625,
              47.025206001585396
            ]
          ]
        ]
      }
}

line_segment(poly)
  • Line Arc : Creates a circular arc, of a circle of the given radius and center point, between bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.
ArgumentTypeDescription
centerFeatureA Point object representing center point of circle
radiusfloatAn int representing radius of the circle
bearing1floatAngle, in decimal degrees, of the first radius of the arc
bearing2floatAngle, in decimal degrees, of the second radius of the arc
optionsfloatA dict representing additional properties,which can be steps which has default values as 64 and units which has default values of km
ReturnTypeDescription
line stringFeatureA Line String feature object.
from turfpy.misc import line_arc
from geojson import Feature, Point

center = Feature(geometry=Point((-75, 40)))
radius = 5
bearing1 = 25
bearing2 = 47

line_arc(center=center, radius=radius, bearing1=bearing1, bearing2=bearing2)
  • Line Arc : Creates a circular sector of a circle of given radius and center Point , between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.
ArgumentTypeDescription
centerFeatureA Point object representing center point of circle
radiusfloatAn int representing radius of the circle
bearing1floatAngle, in decimal degrees, of the first radius of the arc
bearing2floatAngle, in decimal degrees, of the second radius of the arc
optionsfloatA dict representing additional properties, which can be steps which has default values as 64, units which has default values of km, and properties which will be added to resulting Feature as properties.
ReturnTypeDescription
polygonFeatureA polygon feature object.
from turfpy.misc import sector
from geojson import Feature, Point

center = Feature(geometry=Point((-75, 40)))
radius = 5
bearing1 = 25
bearing2 = 45

feature = sector(center, radius, bearing1, bearing2, options={"properties":{"length":3}})