Methods

Methods

Contents

Booleans

Turf.clockwiseMethod.
clockwise(line::Union{LineString, Vector{Position}})::Bool

Take a ring and return true or false whether or not the ring is clockwise or counter-clockwise.

Examples

julia> line = LineString([[0, 0], [1, 1], [1, 0], [0, 0]])
LineString(Array{Float64,1}[[0.0, 0.0], [1.0, 1.0], [1.0, 0.0], [0.0, 0.0]])

julia> clockwise(line)
true
source
Turf.concaveMethod.
concave(poly::Polygon)::Bool

Take a polygon and return true or false as to whether it is concave or not.

Examples

julia> poly = Polygon([[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]])
Polygon(Array{Array{Float64,1},1}[[[0.0, 0.0], [0.0, 1.0], [1.0, 1.0], [1.0, 0.0], [0.0, 0.0]]])

julia> concave(poly)
false
source
Turf.containsMethod.
contains(ft1::AbstractGeometry, ft2::AbstractGeometry)::Bool

Return true if the second geometry is completely contained by the first geometry. The interiors of both geometries must intersect and, the interior and boundary of the secondary (geometry b) must not intersect the exterior of the primary (geometry a). contains returns the exact opposite result of within.

Examples

julia> line = LineString([[1, 1], [1, 2], [1, 3], [1, 4]])
LineString(Array{Float64,1}[[1.0, 1.0], [1.0, 2.0], [1.0, 3.0], [1.0, 4.0]])

julia> point = Point([1, 2])
Point([1.0, 2.0])

julia> contains(line, point)
true
source
Turf.crossesMethod.
 crosses(ft1::AbstractGeometry, ft2::AbstractGeometry)::Bool

Return true if the intersection results in a geometry whose dimension is one less than the maximum dimension of the two source geometries and the intersection set is interior to both source geometries.

Examples

julia> line = LineString([[1, 1], [1, 2], [1, 3], [1, 4]])
LineString(Array{Float64,1}[[1.0, 1.0], [1.0, 2.0], [1.0, 3.0], [1.0, 4.0]])

julia> line2 = LineString([[-2, 2], [4, 2]])
LineString(Array{Float64,1}[[-2.0, 2.0], [4.0, 2.0]])

julia> crosses(line2, line)
true
source
Turf.disjointMethod.
disjoint(geom1::AbstractGeometry, geom2::AbstractGeometry)::Bool

Return true if the intersection of the two geometries is an empty set.

Examples

julia> poly = Polygon([[[-1, 2], [3, 2], [3, 3], [-1, 3], [-1, 2]]])
Polygon(Array{Array{Float64,1},1}[[[-1.0, 2.0], [3.0, 2.0], [3.0, 3.0], [-1.0, 3.0], [-1.0, 2.0]]])

julia> point = Point([1, 1])
Point([1.0, 1.0])

julia> disjoint(poly, point)
true
source
line_intersects(line1::AbstractLineString, line2::AbstractLineString)

Find a point that intersects LineStrings with two coordinates each.

Examples

julia> line1 = LineString([[124.584961,-12.768946],[126.738281,-17.224758]])
LineString(Array{Float64,1}[[124.585, -12.7689], [126.738, -17.2248]])

julia> line2 = LineString([[123.354492,-15.961329],[127.22168,-14.008696]])
LineString(Array{Float64,1}[[123.354, -15.9613], [127.222, -14.0087]])

julia> line_intersects(line1, line2)
Point([125.584, -14.8357])
source
Turf.overlapMethod.
overlap(feat1::AbstractFeature, feat2::AbstractFeature)::Bool

Compare two Features of the same dimension and return true if their intersection set results in a geometry different from both but of the same dimension. It applies to Polygon/Polygon, LineString/LineString, Multipoint/Multipoint, MultiLineString/MultiLineString and MultiPolygon/MultiPolygon.

source
Turf.overlapMethod.
overlap(geom1::AbstractGeometry, geom2::AbstractGeometry)::Bool

Compare two Geometries of the same dimension and return true if their intersection set results in a geometry different from both but of the same dimension. It applies to Polygon/Polygon, LineString/LineString, Multipoint/Multipoint, MultiLineString/MultiLineString and MultiPolygon/MultiPolygon.

Examples

julia> poly1 = Polygon([[[0,0],[0,5],[5,5],[5,0],[0,0]]])
Polygon(Array{Array{Float64,1},1}[[[0.0, 0.0], [0.0, 5.0], [5.0, 5.0], [5.0, 0.0], [0.0, 0.0]]])

julia> poly2 = Polygon([[[1,1],[1,6],[6,6],[6,1],[1,1]]])
Polygon(Array{Array{Float64,1},1}[[[1.0, 1.0], [1.0, 6.0], [6.0, 6.0], [6.0, 1.0], [1.0, 1.0]]])

julia> overlap(poly1, poly2)
true
source
Turf.parallelMethod.
parallel(line1::LineString, line2::LineString)::Bool

Return true if each segment of line1 is parallel to the correspondent segment of line2

Examples

julia> line1 = LineString([[9.170356, 45.477985], [9.164434, 45.482551], [9.166644, 45.484003]])
LineString(Array{Float64,1}[[9.17036, 45.478], [9.16443, 45.4826], [9.16664, 45.484]])

julia> line2 = LineString([[9.169356, 45.477985], [9.163434, 45.482551], [9.165644, 45.484003]])
LineString(Array{Float64,1}[[9.16936, 45.478], [9.16343, 45.4826], [9.16564, 45.484]])

julia> parallel(line1, line2)
true
source
Turf.point_in_polygonFunction.
point_in_polygon(point::Point, polygon::Union{Polygon, MultiPolygon}, ignoreBoundary::Bool=false)::Bool

Take a Point and a Polygon and determine if the point resides inside the polygon. The polygon can be convex or concave. The function accounts for holes.

Examples

julia> point = Point([-77, 44])
Point([-77.0, 44.0])

julia> poly = Polygon([[ [-81, 41], [-81, 47], [-72, 47], [-72, 41], [-81, 41]]])
Polygon(Array{Array{Float64,1},1}[[[-81.0, 41.0], [-81.0, 47.0], [-72.0, 47.0], [-72.0, 41.0], [-81.0, 41.0]]])

julia> point_in_polygon(point, poly)
true
source
Turf.point_on_lineFunction.
point_on_line(point::Point, line::LineString, ignoreEndVertices::Bool=false)::Bool

Return true if a point is on a line. Accept a optional parameter to ignore the start and end vertices of the linestring.

Examples

julia> point = Point([1,1])
Point([1.0, 1.0])

julia> line = LineString([[0, 0], [3, 3], [4, 4]])
LineString(Array{Float64,1}[[0.0, 0.0], [3.0, 3.0], [4.0, 4.0]])

julia> point_on_line(point, line)
true
source
Turf.withinMethod.
within(ft1::AbstractGeometry, ft2::AbstractGeometry)::Bool

Return true if the first geometry is completely within the second geometry. The interiors of both geometries must intersect and, the interior and boundary of the primary (geometry a) must not intersect the exterior of the secondary (geometry b). within returns the exact opposite result of contains.

Examples

julia> line = LineString([[1, 1], [1, 2], [1, 3], [1, 4]])
LineString(Array{Float64,1}[[1.0, 1.0], [1.0, 2.0], [1.0, 3.0], [1.0, 4.0]])

julia> point = Point([1, 2])
Point([1.0, 2.0])

julia> within(point, line)
true
source

Conversion

Turf.areaMethod.
area(geojson::T) where {T <: Union{AbstractFeatureCollection, AbstractGeometry}}

Take one or more features and return their area in square meters.

source
Turf.cleanFunction.
clean(geojson::AbstractGeometry, mutate::Bool=false)

Remove redundant coordinates from any GeoJSON Geometry.

Examples

julia> line = LineString([[0, 0], [0, 2], [0, 5], [0, 8], [0, 10], [0, 10]])
LineString(Array{Float64,1}[[0.0, 0.0], [0.0, 2.0], [0.0, 5.0], [0.0, 8.0], [0.0, 10.0], [0.0, 10.0]])

julia> clean(line)
LineString(Array{Float64,1}[[0.0, 0.0], [0.0, 10.0]])
source
Turf.cleanFunction.
clean(geojson::AbstractFeature, mutate::Bool=false)

Remove redundant coordinates from any GeoJSON Feature.

source
Turf.clean!Method.
clean!(geojson::AbstractFeature)

Remove redundant coordinates from any GeoJSON Feature. It modifies the GeoJSON geometry in place.

source
Turf.clean!Method.
clean!(geojson::AbstractGeometry)

Remove redundant coordinates from any GeoJSON Geometry. It modifies the GeoJSON geometry in place.

source
Turf.convert_areaFunction.
convert_area(area::Real, originalUnit::String="meters", finalUnit::String="kilometers")::Real

Convert an area to the requested unit.

source
Turf.convert_lengthFunction.
convert_length(length::Real, originalUnit::String="kilometers", finalUnit::String="kilometers")::Real

Convert a length to the requested unit.

source
length_to_degrees(distance::Real, units::String="kilometers")::Real

Convert a distance measurement (assuming a spherical Earth) from a real-world unit into degrees. Valid units: miles, nauticalmiles, inches, yards, meters, metres, centimeters, kilometres, feet

source
length_to_radians(distance::Real, units::String="kilometers")::Real

Convert a distance measurement (assuming a spherical Earth) from a real-world unit to radians. Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet

source
radians_to_length(radians::Real, units::String="kilometers")::Real

Convert a distance measurement (assuming a spherical Earth) from radians to a more friendly unit. Valid units: miles, nauticalmiles, inches, yards, meters, metres, kilometers, centimeters, feet

source
Turf.to_WGS84Method.
to_WGS84(pos::Point)

Convert 900913 x/y values to lon/lat.

source
Turf.to_mercatorMethod.
to_mercator(pos::Point)

Convert lon/lat values to 900913 x/y.

source

Grids

Turf.hexgridMethod.
 hexgrid(bbox::Vector{T}, cellSide::Real, mask::Union{Polygon, Nothing}=nothing, triangles::Bool=false, units::String="kilometers") where {T <: Real}

Take a bounding box and the diameter of the cell and return a FeatureCollection of flat-topped hexagons or triangles Polygon aligned in an "odd-q" vertical grid as described in Hexagonal Grids.

source
Turf.point_gridMethod.
point_grid(bbox::Vector{T}, cellSide::Real, mask::Union{Polygon, Nothing}=nothing, units::String="kilometers") where {T <: Real}

Create a Point grid from a bounding box

Examples

julia> bbox = [-1, 2, 1, 3]
4-element Array{Int64,1}:
 -1
  2
  1
  3

julia> point_grid(bbox, 100)
FeatureCollection{Feature}(Feature[Feature(Point([-0.899869, 2.05034]), Dict{String,Any}()), Feature(Point([-0.899869, 2.94966]), Dict{String,Any}()), Feature(Point([0.0, 2.05034]), Dict{String,Any}()), Feature(Point([0.0, 2.94966]), Dict{String,Any}()), Feature(Point([0.899869, 2.05034]), Dict{String,Any}()), Feature(Point([0.899869, 2.94966]), Dict{String,Any}())], nothing, nothing)
source
rectangle_grid(bbox::Vector{T}, width::Real, height::Real, mask::Union{Polygon, Nothing}=nothing, units::String="kilometers") where {T <: Real}

Create a grid of rectangles from a bounding box.

Examples

julia> bbox = [-1, 2, 1, 3]
4-element Array{Int64,1}:
 -1
  2
  1
  3

julia> rectangle_grid(bbox, 150, 100)
FeatureCollection{Feature}(Feature[Feature(Polygon(Array{Array{Float64,1},1}[[[-0.674901, 2.05034], [-0.674901, 2.94966], [0.674901, 2.94966], [0.674901, 2.05034], [-0.674901, 2.05034]]]), Dict{String,Any}())], nothing, nothing)
source
Turf.square_gridMethod.
square_grid(bbox::Vector{T}, cell_side::Real, mask::Union{Polygon, Nothing}=nothing, units::String="kilometers") where {T <: Real}

Create a square grid from a bounding box.

Examples

julia> bbox = [-1, 2, 1, 3]
4-element Array{Int64,1}:
 -1
  2
  1
  3

julia> square_grid(bbox, 100)
FeatureCollection{Feature}(Feature[Feature(Polygon(Array{Array{Float64,1},1}[[[-0.899869, 2.05034], [-0.899869, 2.94966], [0.0, 2.94966], [0.0, 2.05034], [-0.899869, 2.05034]]]), Dict{String,Any}()), Feature(Polygon(Array{Array{Float64,1},1}[[[0.0, 2.05034], [0.0, 2.94966], [0.899869, 2.94966], [0.899869, 2.05034], [0.0, 2.05034]]]), Dict{String,Any}())], nothing, nothing)
source
Turf.triangle_gridMethod.
triangle_grid(bbox::Vector{T}, cell_side::Real, mask::Union{Polygon, Nothing}=nothing, units::String="kilometers") where {T <: Real}

Take a bounding box and a cell depth and returns a set of triangular Polygons in a grid.

Examples

julia> bbox = [-1, 2, 1, 3]
4-element Array{Int64,1}:
 -1
  2
  1
  3

julia> triangle_grid(bbox, 200)
FeatureCollection{Feature}(Feature[Feature(Polygon(Array{Array{Float64,1},1}[[[-1.0, 2.0], [-1.0, 3.79864], [0.799737, 2.0], [-1.0, 2.0]]]), Dict{String,Any}()), Feature(Polygon(Array{Array{Float64,1},1}[[[-1.0, 3.79864], [0.799737, 3.79864], [0.799737, 2.0], [-1.0, 3.79864]]]), Dict{String,Any}()), Feature(Polygon(Array{Array{Float64,1},1}[[[0.799737, 2.0], [0.799737, 3.79864], [2.59947, 3.79864], [0.799737, 2.0]]]), Dict{String,Any}()), Feature(Polygon(Array{Array{Float64,1},1}[[[0.799737, 2.0], [2.59947, 3.79864], [2.59947, 2.0], [0.799737, 2.0]]]), Dict{String,Any}())], nothing, nothing)
source

Measurement

Turf.distanceFunction.
distance(from::Position, to::Position, units::String="kilometers")

Calculate the distance between two Points or Positions in degrees, radians, miles, or kilometers. The distance is calculated using the Haversine formula to account for global curvature.

Examples

julia> point1 = Point([35, 45])
Point([35.0, 45.0])

julia> point2 = Point([38, 43])
Point([38.0, 43.0])

julia> distance(point1, point2)
327.1241022693492

julia> distance(point1, point2, "miles")
203.26549343667307

julia> distance(point1, point2, "degrees")
2.9384603841845878
source
distance_to_segment(point::Point, first::Point, last::Point, units::String="degrees", method::String="planar")

Return the distance between a point P on a segment AB.

source
distance_weight(; geojson::T, treshold::Real=10000, p::Integer=2, binary::Bool=false, alpha::Real=-1., standardization::Bool=false) where {T <: AbstractFeatureCollection}

Calculate the Minkowski p-norm distance between two Points.

source
Turf.midpointMethod.
midpoint(first::Point, second::Point)

Take two Points and returns a point midway between them. The midpoint is calculated geodesically, meaning the curvature of the earth is taken into account.

Examples

julia> point = Point([35, 45])
Point([35.0, 45.0])

julia> point1 = Point([33, 42])
Point([33.0, 42.0])

julia> midpoint(point, point1)
Point([33.9751, 43.5044])
source
Turf.nearestpointMethod.
nearestpoint(target::Point, points::Vector{Point})

Take a reference Point and an array of Points and return the point from the array closest to the reference. This calculation is geodesic.

Examples

julia> point = Point([35, 45])
Point([35.0, 45.0])

julia> point1 = Point([33, 42])
Point([33.0, 42.0])

julia> point2 = Point([39, 41])
Point([39.0, 41.0])

julia> point3 = Point([35, 39])
Point([35.0, 39.0])

julia> nearestpoint(point, [point1, point2, point3])
Point([33.0, 42.0])
source
Turf.pnorm_distanceFunction.
pnorm_distance(point1::Point, point2::Point, p::Integer=2)::Real

Calculate the Minkowski p-norm distance between two Points.

Examples

julia> point = Point([35, 45])
Point([35.0, 45.0])

julia> point1 = Point([33, 42])
Point([33.0, 42.0])

julia> pnorm_distance(point, point1)
3.605551275463989

julia> pnorm_distance(point, point1, 1)
5.0

julia> pnorm_distance(point, point1, 3)
3.2710663101885897
source
point_to_line_distance(point::Point, line::LineString, units::String="kilometers", method::String="geodesic")

Return the minimum distance between a Point and a LineString, being the distance from a line the minimum distance between the point and any segment of the LineString.

Examples

julia> point = Point([35, 45])
Point([35.0, 45.0])

julia> line = LineString([[35, 42], [38, 42.5], [40, 43]])
LineString(Array{Float64,1}[[35.0, 42.0], [38.0, 42.5], [40.0, 43.0]])

julia> point_to_line_distance(point, line)
326.92768049303146

julia> point_to_line_distance(point, line, "degrees", "planar")
2.936700172184462

julia> point_to_line_distance(point, line, "degrees")
2.9366959846668
source
Turf.rhumb_distanceFunction.
rhumb_distance(from::Position, to::Position, units::String="kilometers")

Calculate the distance along a rhumb line between two Points or Positions in degrees, radians, miles, or kilometers.

Examples

julia> point1 = Point([35, 45])
Point([35.0, 45.0])

julia> point2 = Point([38, 43])
Point([38.0, 43.0])

julia> rhumb_distance(point1, point2)
327.1421400706353

julia> rhumb_distance(point1, point2, "miles")
203.2767016067636

julia> rhumb_distance(point1, point2, "degrees")
2.9386224124916716
source
Turf.bearingFunction.
bearing(start::Position, stop::Position, final::Bool=false)

Take two Points or Positions and finds the geographic bearing between them, i.e. the angle measured in degrees from the north line (0 degrees).

Examples

julia> start = Position([-75, 45])
2-element Array{Float64,1}:
 -75.0
  45.0

julia> stop = Position([20, 60])
2-element Array{Float64,1}:
 20.0
 60.0

julia> bearing(start, stop)
37.75495852601734
source
bearing_to_azimuth(bearing::Real)::Real

Convert any bearing angle from the north line direction (positive clockwise) and return an angle between 0-360 degrees (positive clockwise), 0 being the north line.

Examples

julia> bearing_to_azimuth(40)
40

julia> bearing_to_azimuth(-105)
255

julia> bearing_to_azimuth(410)
50
source
Turf.rhumb_bearingFunction.
rhumb_bearing(start::Position, stop::Position, final::Bool=false)

Take two Positions and finds the bearing angle between them along a Rhumb line i.e. the angle measured in degrees start the north line (0 degrees).

Examples

julia> start = Position([-75, 45])
2-element Array{Float64,1}:
 -75.0
  45.0

julia> stop = Position([20, 60])
2-element Array{Float64,1}:
 20.0
 60.0

julia> rhumb_bearing(start, stop)
75.28061364784332
source
Turf.angle_adjacentFunction.
angle_adjacent(start::Position, mid::Position, stop::Position, explementary::Bool=false, mercator::Bool=false)

Find the angle formed by two adjacent segments defined by 3 points. The result will be the (positive clockwise) angle with origin on the start-mid segment, or its explementary angle if required.

Examples

julia> p1 = Point([-35, 55])
Point([-35.0, 55.0])

julia> p2 = Point([-34.8, 57.5])
Point([-34.8, 57.5])

julia> p3 = Point([-33.4, 59.1])
Point([-33.4, 59.1])

julia> angle_adjacent(p1, p2, p3, false, false)
202.8279033760424

julia> angle_adjacent(p1, p2, p3, true, false) # explementary angle
157.1720966239576
source
Turf.centerMethod.
center(geojson::T) where {T <: AbstractGeometry}

Take a GeoJson Geometry and return the absolute center point.

Examples

julia> line = LineString([[1, 2], [4, 6], [8, 9.5], [12, 13.4]])
LineString(Array{Float64,1}[[1.0, 2.0], [4.0, 6.0], [8.0, 9.5], [12.0, 13.4]])

julia> center(line)
Point([6.5, 7.7])
source
Turf.centroidMethod.
centroid([geojson::T])::Point where {T <: AbstractFeatureCollection}

Takes one or more features and calculates the centroid using the mean of all vertices. This lessens the effect of small islands and artifacts when calculating the centroid of a set of polygons.

Examples

julia> line = LineString([[1, 2], [4, 6], [8, 9.5], [12, 13.4]])
LineString(Array{Float64,1}[[1.0, 2.0], [4.0, 6.0], [8.0, 9.5], [12.0, 13.4]])

julia> centroid(line)
Point([6.25, 7.725])
source
Turf.centroidMethod.
centroid([geojson::T])::Point where {T <: AbstractGeometry}

Takes one or more features and calculates the centroid using the mean of all vertices. This lessens the effect of small islands and artifacts when calculating the centroid of a set of polygons.

Examples

julia> line = LineString([[1, 2], [4, 6], [8, 9.5], [12, 13.4]])
LineString(Array{Float64,1}[[1.0, 2.0], [4.0, 6.0], [8.0, 9.5], [12.0, 13.4]])

julia> centroid(line)
Point([6.25, 7.725])
source
Turf.masscenterMethod.
masscenter(geojson::T) where {T <: AbstractGeometry}

Take any GeoJson Geometry and return its center of mass using this formula: Centroid of Polygon.

Examples

julia> line = LineString([[1, 2], [4, 6], [8, 9.5], [12, 13.4]])
LineString(Array{Float64,1}[[1.0, 2.0], [4.0, 6.0], [8.0, 9.5], [12.0, 13.4]])

julia> masscenter(line)
Point([6.25, 7.725])
source
Turf.meancenterMethod.
meancenter(geojson::T, weight::Real=1.) where {T <: Union{AbstractGeometry, AbstractFeatureCollection}}

Take a GeoJson Geometry and return the mean center. Can be weighted.

Examples

julia> line = LineString([[1, 2], [4, 6], [8, 9.5], [12, 13.4]])
LineString(Array{Float64,1}[[1.0, 2.0], [4.0, 6.0], [8.0, 9.5], [12.0, 13.4]])

julia> meancenter(line)
Point([6.25, 7.725])
source
Turf.mediancenterMethod.
mediancenter(geojson::T, weight::Real=1., tol::Real=0.001, count::Integer=10) where {T <: AbstractFeatureCollection}

Take a FeatureCollection of points and calculate the median center, algorithimically. The median center is understood as the point that is requires the least total travel from all other points.

Examples

julia> fc = FeatureCollection([Feature(Point([0, 0])),Feature(Point([9, 9])), Feature(Point([9.25, 9.25])),
             Feature(Point([9.5, 9.5])), Feature(Point([9.75, 9.75])), Feature(Point([10, 10]))])
FeatureCollection{Feature}(Feature[Feature(Point([0.0, 0.0]), Dict{String,Any}()), Feature(Point([9.0, 9.0]), Dict{String,Any}()), Feature(Point([9.25, 9.25]), Dict{String,Any}()), Feature(Point([9.5, 9.5]), Dict{String,Any}()), Feature(Point([9.75, 9.75]), Dict{String,Any}()), Feature(Point([10.0, 10.0]), Dict{String,Any}())], nothing, nothing)

julia> mediancenter(fc)
Point([9.25425, 9.25425])
source
Turf.destinationFunction.
destination(origin::Position, distance::Real, bearing::Real, units::String="kilometers")

Take a Point or a Position and calculate the location of a destination point given a distance in degrees, radians, miles, or kilometers; and bearing in degrees. The destination is calculated using the Haversine formula to account for global curvature.

Examples

julia> point = Point([-75, 38])
Point([-75.0, 38.0])

julia> destination(point, 100, 0)
Point([-75.0, 38.8993])

julia> destination(point, 100, 45)
Point([-74.1859, 38.6331])

julia> destination(point, 50, 0, "miles")
Point([-75.0, 38.7237])
source
rhumb_destination(origin::Position, distance::Real, bearing::Real, units::String="kilometers")

Take a Point or a Position and return the destination Point having travelled the given distance along a Rhumb line from the origin Point with the (varant) given bearing.

Examples

julia> point = Point([-75, 38])
Point([-75.0, 38.0])

julia> rhumb_destination(point, 100, 0)
Point([-75.0, 38.8993])

julia> rhumb_destination(point, 100, 45)
Point([-74.1895, 38.6359])

julia> rhumb_destination(point, 50, 0, "miles")
Point([-75.0, 38.7237])
source
Turf.ellipseMethod.
ellipse(; center::Point, xAxis::Real, yAxis::Real, steps::Integer=64, angle::Real=0., pivot::Union{Point, Nothing}=nothing, units::String="kilometers")

Take a Point and calculates the ellipse polygon given two semi-axes expressed in variable units and steps for precision.

Examples

julia> center = Point([10, 45])
Point([10.0, 45.0])

julia> ellipse(center=center, xAxis=20, yAxis=7.5, steps=10)
Polygon(Array{Array{Float64,1},1}[[[10.0872, 45.0634], [10.0218, 45.0672], [9.97817, 45.0672], [9.91279, 45.0634], [9.74563, 45.0], [9.91279, 44.9366], [9.97817, 44.9328], [10.0218, 44.9328], [10.0872, 44.9366], [10.2544, 45.0], [10.0872, 45.0634]]])
source
Turf.circleMethod.
circle(; center::Union{Point, Position}, radius::Real=5., steps::Integer=64, units::String="kilometers")

Take a Point or a Position and calculate the circle polygon given a radius in degrees, radians, miles, or kilometers; and steps for precision.

Examples

julia> point = Point([35, 45])
Point([35.0, 45.0])

julia> circle(center=point, steps=5)
Polygon(Array{Array{Float64,1},1}[[[34.9395, 45.0139], [34.9626, 44.9636], [35.0374, 44.9636], [35.0605, 45.0139], [35.0, 45.045], [34.9395, 45.0139]]])

julia> circle(center=point, radius=2.5, steps=5, units="degrees")
Polygon(Array{Array{Float64,1},1}[[[31.5893, 45.7231], [32.99, 42.9571], [37.01, 42.9571], [38.4107, 45.7231], [35.0, 47.5029], [31.5893, 45.7231]]])
source
Turf.sectorFunction.
sector(center::Point, radius::Real, bearing1::Real, bearing2::Real, steps::Integer=64, units::String="kilometers")

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.

Examples

julia> point = Point([35, 45])
Point([35.0, 45.0])

julia> sector(point, 5, 0, 0.5, 5)
Polygon(Array{Array{Float64,1},1}[[[35.0, 45.0], [35.0, 45.045], [35.0006, 45.045], [35.0, 45.0]]])

julia> sector(point, 5, 0, 270, 5)
Polygon(Array{Array{Float64,1},1}[[[35.0, 45.0], [35.0, 45.045], [35.0605, 45.0139], [35.0374, 44.9636], [34.9626, 44.9636], [34.9364, 45.0], [35.0, 45.0]]])
source
Turf.linearcFunction.
linearc(center::Point, radius::Real, bearing1::Real, bearing2::Real, steps::Real=64., units::String="kilometers")

Create 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.

Examples

julia> point = Point([35, 45])
Point([35.0, 45.0])

julia> linearc(point, 5, 0, 10, 5)
LineString(Array{Float64,1}[[35.0, 45.045], [35.0111, 45.0443]])

julia> linearc(point, 5, 0, 270, 5)
LineString(Array{Float64,1}[[35.0, 45.045], [35.0605, 45.0139], [35.0374, 44.9636], [34.9626, 44.9636], [34.9364, 45.0]])
source
Turf.linesegmentMethod.
linesegment(geojson::LineString)

Create a 2-vertex LineString segments from a LineString.

Examples

julia> line = LineString([[0, 1], [2, 3], [3, 3]])
LineString(Array{Float64,1}[[0.0, 1.0], [2.0, 3.0], [3.0, 3.0]])

julia> linesegment(line)
2-element Array{LineString,1}:
 LineString(Array{Float64,1}[[0.0, 1.0], [2.0, 3.0]])
 LineString(Array{Float64,1}[[2.0, 3.0], [3.0, 3.0]])
source
Turf.squareMethod.
square(bbox::Vector{T}) where {T <: Real}

Take a bounding box and calculates the minimum square bounding box that would contain the input.

Examples

julia> bbox = [-1, 1, 2, 3.5]
4-element Array{Float64,1}:
 -1.0
  1.0
  2.0
  3.5

julia> square(bbox)
4-element Array{Float64,1}:
 -1.0
  0.75
  2.0
  3.75
source

Misc

Turf.bboxMethod.
 bbox(geojson::T) where {T<: AbstractFeature}

Take a Feature and return a bounding box around its geometry.

source
Turf.bboxMethod.
bbox(geojson::T) where {T<:AbstractFeatureCollection}

Take a set of features, calculate the bbox of all input features, and returns a bounding box.

source
Turf.bboxMethod.
bbox(geojson::T) where {T <: AbstractGeometry}

Take a GeoJSON Geometry and calculate its bounding box.

source
Turf.bbox_polygonMethod.
bbox_polygon(bbox::Vector{T}) where {T <: Real}

Take a bbox and return an equivalent Polygon.

source
Turf.bezierMethod.
bezier(line::LineString; resolution::Real=10000, sharpness::Real=0.85)

Take a LineString and returns a curved version by applying a Bezier spline algorithm.

source
Turf.planepointMethod.
planepoint(point::Point, triangle::Polygon)

Take a triangular plane as a Polygon and a Point within that triangle and returns the z-value at that point.

Examples

julia> point = Point([-175, 22])
Point([-175.0, 22.0])

julia> triangle = Polygon([[-174.55, 32.54, 55], [-186.94, 17.64, 24.5], [-167.95, 17.81, 33.6], [-174.55, 32.54, 55]])
Polygon(Array{Array{Float64,1},1}[[[-174.55, 32.54, 55.0], [-186.94, 17.64, 24.5], [-167.95, 17.81, 33.6], [-174.55, 32.54, 55.0]]])

julia> planepoint(point, triangle)
37.28550123965308
source

Transformation

Turf.combineMethod.
combine([ft::FeatureCollection])

Combine a FeatureCollection of Point, LineString, or Polygon features into MultiPoint, MultiLineString, or MultiPolygon features.

Examples

julia> l1 = LineString([[102.0,-10.0],[130.0,4.0]])
LineString(Array{Float64,1}[[102.0, -10.0], [130.0, 4.0]])

julia> l2 = LineString([[40.0,-20.0],[150.0,18.0]])
LineString(Array{Float64,1}[[40.0, -20.0], [150.0, 18.0]])

julia> combine(FeatureCollection([Feature(l1), Feature(l2)]))
FeatureCollection{Feature}(Feature[Feature(MultiLineString(Array{Array{Float64,1},1}[[[102.0, -10.0], [130.0, 4.0], [40.0, -20.0], [150.0, 18.0]]]), Dict{String,Any}())], nothing, nothing)
source
Turf.convert_toFunction.
convert_to([geojson::AbstractGeometry[, projection::String]], mutate::Bool=false)

Convert a GeoJSON geojsonect to the defined projection.

source
Turf.explodeMethod.
explode([geojson::T], pointsOnly::Bool=false)::FeatureCollection where {T <: Union{AbstractFeatureCollection, AbstractGeometry}}

Takes a Geometry or a FeatureCollection and returns all positions as Points.

Examples

julia> poly = Polygon([[[100, 0], [101, 0], [101, 1], [100, 1], [100, 0]]])
Polygon(Array{Array{Float64,1},1}[[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]]])

julia> explode(poly, true)
5-element Array{Point,1}:
 Point([100.0, 0.0])
 Point([101.0, 0.0])
 Point([101.0, 1.0])
 Point([100.0, 1.0])
 Point([100.0, 0.0])
source
Turf.flipMethod.
flip([geojson::T], mutate::Bool=false) where {T <: Union{AbstractFeature, AbstractGeometry}}

Take input Features and Geometries and flips all of their coordinates from [x, y] to [y, x].

Examples

julia> point = Point([77.34374999999999,43.58039085560784,3000])
Point([77.3437, 43.5804, 3000.0])

julia> flip(point)
Point([43.5804, 77.3437, 3000.0])
source
Turf.lineclipMethod.

Cohen-Sutherland line clippign algorithm, adapted to efficiently to handle polylines rather than just segments

source
polygon_tangents(pt::Point, poly::Polygon)

Finds the tangents of a Polygon from a Point.

Examples

```jldoctest julia> point = Point([92.46093749999999,54.67383096593114]) Point([92.4609, 54.6738])

julia> poly = Polygon([[[100, 0], [101, 0], [101, 1], [100, 1], [100, 0]]]) Polygon(Array{Array{Float64,1},1}[[[100.0, 0.0], [101.0, 0.0], [101.0, 1.0], [100.0, 1.0], [100.0, 0.0]]])

julia> poly = Polygon([[[48.1641, 20.6328], [76.6406, 20.6328], [76.6406, 38.8226], [48.1641, 38.8226], [48.1641, 20.6328]]]) Polygon(Array{Array{Float64,1},1}[[[48.1641, 20.6328], [76.6406, 20.6328], [76.6406, 38.8226], [48.1641, 38.8226], [48.1641, 20.6328]]])

julia> polygon_tangents(point, poly) FeatureCollection{Feature}(Feature[Feature(Point([48.1641, 38.8226]), Dict{String,Any}()), Feature(Point([76.6406, 20.6328]), Dict{String,Any}())], nothing, nothing) ```

source
polygon_to_line([poly::Polygon])

Converts a Polygon to LineString or MultiLineString

Examples

julia> poly = Polygon([[[-2.275543, 53.464547],[-2.275543, 53.489271],[-2.215118, 53.489271],[-2.215118, 53.464547],[-2.275543, 53.464547]]])
Polygon(Array{Array{Float64,1},1}[[[-2.27554, 53.4645], [-2.27554, 53.4893], [-2.21512, 53.4893], [-2.21512, 53.4645], [-2.27554, 53.4645]]])

julia> polygon_to_line(poly)
LineString(Array{Float64,1}[[-2.27554, 53.4645], [-2.27554, 53.4893], [-2.21512, 53.4893], [-2.21512, 53.4645], [-2.27554, 53.4645]])
source
Turf.polygonclipMethod.

Sutherland-Hodgeman polygon clipping algorithm.

source
Turf.scaleFunction.
scale([feature::Feature[, factor::Real]], origin::String="centroid")

Scale a Feature.

Examples

julia> feature = Feature(Polygon([[[0, 29], [3.5, 29], [2.5, 32], [0, 29]]]))
Feature(Polygon(Array{Array{Float64,1},1}[[[0.0, 29.0], [3.5, 29.0], [2.5, 32.0], [0.0, 29.0]]]), Dict{String,Any}())

julia> scale(feature, 0.1)
Feature(Polygon(Array{Array{Float64,1},1}[[[1.3495, 29.675], [1.70067, 29.675], [1.59896, 29.975], [1.3495, 29.675]]]), Dict{String,Any}())
source
Turf.simplifyFunction.
simplify(geojson::FeatureCollection, tolerance::Real=1., hq::Bool=false, mutate::Bool=false)

Take a FeatureCollection and return a simplified version. Internally uses an adaptation of simplify-js to perform simplification using the Ramer-Douglas-Peucker algorithm.

Examples

julia> poly = Polygon([[
    [-70.603637, -33.399918],
    [-70.614624, -33.395332],
    [-70.639343, -33.392466],
    [-70.659942, -33.394759],
    [-70.683975, -33.404504],
    [-70.697021, -33.419406],
    [-70.701141, -33.434306],
    [-70.700454, -33.446339],
    [-70.694274, -33.458369],
    [-70.682601, -33.465816],
    [-70.668869, -33.472117],
    [-70.646209, -33.473835],
    [-70.624923, -33.472117],
    [-70.609817, -33.468107],
    [-70.595397, -33.458369],
    [-70.587158, -33.442901],
    [-70.587158, -33.426283],
    [-70.590591, -33.414248],
    [-70.594711, -33.406224],
    [-70.603637, -33.399918]]])

julia> simplify(poly, 0.01)
Polygon(Array{Array{Float64,1},1}[[[-70.6036, -33.3999], [-70.684, -33.4045], [-70.7011, -33.4343], [-70.6943, -33.4584], [-70.6689, -33.4721], [-70.6098, -33.4681], [-70.5872, -33.4429], [-70.6036, -33.3999]]])
source
Turf.simplifyFunction.
simplify(geojson::AbstractFeature, tolerance::Real=1., hq::Bool=false, mutate::Bool=false)

Take a GeoJSON Feature and return a simplified version. Internally uses an adaptation of simplify-js to perform simplification using the Ramer-Douglas-Peucker algorithm.

source
Turf.simplifyFunction.
simplify(geojson::AbstractGeometry, tolerance::Real=1., hq::Bool=false, mutate::Bool=false)

Take a GeoJSON Geometry and return a simplified version. Internally uses an adaptation of simplify-js to perform simplification using the Ramer-Douglas-Peucker algorithm.

source
Turf.simplify!Function.
simplify(geojson::AbstractFeature, tolerance::Real=1., hq::Bool=false)

Take a GeoJSON Feature and return a simplified version, modifying the original Feature. Internally uses an adaptation of simplify-js to perform simplification using the Ramer-Douglas-Peucker algorithm.

source
Turf.simplify!Function.
simplify(geojson::AbstractGeometry, tolerance::Real=1., hq::Bool=false)

Take a GeoJSON Geometry and return a simplified version, modifying the original Geometry. Internally uses an adaptation of simplify-js to perform simplification using the Ramer-Douglas-Peucker algorithm.

source
Turf.simplify!Function.
simplify(geojson::FeatureCollection, tolerance::Real=1., hq::Bool=false)

Take a FeatureCollection and return a simplified version, modifying the original FeatureCollection. Internally uses an adaptation of simplify-js to perform simplification using the Ramer-Douglas-Peucker algorithm.

source
Turf.tagMethod.
tag(fc1::FeatureCollection, fc2::FeatureCollection, in_field::String, out_field::String)::FeatureCollection

Take a set of Points and a set of Polygons and performs a spatial join.

source
transform_rotate([geojson::T[, angle::Real], pivot::Point=nothing, mutate::Bool=false) where {T <: AbstractGeometry}

Rotates any geojson Feature or Geometry of a specified angle, around its centroid or a given pivot point; all rotations follow the right-hand rule.

Examples

julia> point = Point([-75.69926351308823,45.43145021122502])
Point([-75.6993, 45.4315])

julia> transform_rotate(geojson=point, angle=80., pivot=Point([-75.6, 45.3]))
Point([-75.433, 45.3915])
source
transform_scale([geojson::T[, factor::Float64]], origin::String="centroid") where {T <: AbstractFeatureCollection}

Scale a GeoJson from a given point by a factor of scaling (ex: factor=2 would make the GeoJson 200% larger). If a FeatureCollection is provided, the origin point will be calculated based on each individual Feature.

Examples

julia> coll = FeatureCollection([Feature(Point([-75.69926351308823,45.43145021122502])), Feature(Polygon([[[0, 29], [3.5, 29], [2.5, 32], [0, 29]]]))])
FeatureCollection{Feature}(Feature[Feature(Point([-75.6993, 45.4315]), Dict{String,Any}()), Feature(Polygon(Array{Array{Float64,1},1}[[[0.0, 29.0], [3.5, 29.0], [2.5, 32.0], [0.0, 29.0]]]), Dict{String,Any}())], nothing, nothing)

julia> transform_scale(coll, 0.1)
FeatureCollection{Feature}(Feature[Feature(Point([-75.6993, 45.4315]), Dict{String,Any}()), Feature(Polygon(Array{Array{Float64,1},1}[[[1.3495, 29.675], [1.70067, 29.675], [1.59896, 29.975], [1.3495, 29.675]]]), Dict{String,Any}())], nothing, nothing)
source
transform_translate([geojson::T[, distance::R[, direction::R]]], vertical::R=0, mutate::Bool=false, units::String="kilometers") where {T <: Union{AbstractFeature, AbstractGeometry}, R <: Real}

Moves any geojson Feature or Geometry of a specified distance along a Rhumb Line on the provided direction angle.

Examples

julia> poly = Polygon([[[0, 29], [3.5, 29], [2.5, 32], [0, 29]]])
Polygon(Array{Array{Float64,1},1}[[[0.0, 29.0], [3.5, 29.0], [2.5, 32.0], [0.0, 29.0]]])

julia> transform_translate(poly, 300, 70)
Polygon(Array{Array{Float64,1},1}[[[2.91184, 29.9228], [6.41184, 29.9228], [5.50479, 32.9228], [2.91184, 29.9228]]])
source
Turf.intersectionMethod.

Intersect a segment against one of the 4 lines that make up the bbox

source