lawn: Client for 'Turfjs' for 'Geospatial' Analysis

> library(lawn)

バージョン: 0.3.0


関数名 概略
as_feature Convert a FeatureCollection to a Feature
data-types Description of GeoJSON data types
georandom Return a FeatureCollection with N number of features with random coordinates
lawn-package R client for turf.js for geospatial analysis
lawn_aggregate Calculate a series of aggregations for a set of points within polygons
lawn_along Get a point at a distance along a line
lawn_area Calculate the area of a polygon or group of polygons
lawn_average Average of a field among points within polygons
lawn_bbox_polygon Make a polygon from a bounding box
lawn_bearing Get geographic bearing between two points
lawn_bezier Curve a linestring
lawn_buffer Buffer a feature
lawn_center Get center point
lawn_centroid Centroid
lawn_combine Combine singular features into plural versions
lawn_concave Concave hull polygon
lawn_convex Convex hull polygon
lawn_count Count number of points within polygons
lawn_data Data for use in examples
lawn_destination Calculate destination point
lawn_deviation Standard deviation of a field among points within polygons
lawn_distance Distance between two points
lawn_envelope Calculate envelope around features
lawn_erase Erase one polygon from another
lawn_explode Explode vertices to points
lawn_extent Get a bounding box
lawn_featurecollection Create a FeatureCollection
lawn_filter Filter a FeatureCollection by a given property and value
lawn_flip Flip x,y to y,x, and vice versa
lawn_hex_grid Create a HexGrid
lawn_inside Does a point reside inside a polygon
lawn_intersect Intersection
lawn_isolines Generate Isolines
lawn_jenks Get Jenks breaks
lawn_kinks Get points at all self-intersections of a polygon
lawn_line_distance Measure a linestring
lawn_line_slice Slice a line given two points
lawn_linestring Create a linestring
lawn_max Maximum value of a field among points within polygons
lawn_median Median value of a field among points within polygons
lawn_merge Merge polygons
lawn_midpoint Get a point midway between two points
lawn_min Minimum value of a field among points within polygons
lawn_nearest Get nearest point
lawn_planepoint Calculate a Planepoint
lawn_point Create a point
lawn_point_grid Create a PointGrid
lawn_point_on_line Get closest point on linestring to reference point
lawn_point_on_surface Get a point on the surface of a feature
lawn_polygon Create a polygon
lawn_quantile Calculate quantiles
lawn_random Generate random data
lawn_reclass Reclassify properties data
lawn_remove Remove things from a FeatureCollection
lawn_sample Return features from FeatureCollection at random
lawn_simplify Simplify GeoJSON data
lawn_size Expand a bounding box
lawn_square Calculate a square bounding box
lawn_square_grid Create a SquareGrid
lawn_sum Sum of a field among points within polygons
lawn_tag Spatial join of points and polygons
lawn_tin Create a Triangulated Irregular Network
lawn_triangle_grid Create a TriangleGrid
lawn_union Merge polygons
lawn_variance Variance of a field among points within polygons
lawn_within Return points that fall within polygons
print-methods Lawn print methods to provide summary view
view Visualize geojson

georandom

ランダムな空間属性データの作成

Arguments

  • n
  • bbox
  • vertices
  • max_radial_length
> gr_point(n = 4, bbox = NULL)
<FeatureCollection>
  Bounding box: -133.8 -32.8 141.9 53.7
  No. features: 4
  No. points: 8
  Properties: NULL
> gr_position(bbox = NULL)
[1] -42.96173 -56.62047
> gr_polygon(n = 2, vertices = 10, max_radial_length = 10, bbox = NULL)
<FeatureCollection>
  Bounding box: 136.9 -52.5 160.5 83.4
  No. features: 2
  No. points: 44
  Properties: NULL

lawn_average

> lawn_average(polygons = lawn_data$polygons_average,
+              points = lawn_data$points_average,
+              field = 'population')
Error in lawn_average(polygons = lawn_data$polygons_average, points = lawn_data$points_average, : unused argument (field = "population")

lawn_count

> lawn_count(polygons = lawn_data$polygons_count, points = lawn_data$points_count)
Error in sprintf("var fc = turf.collect(%s, %s, '%s', 'values');", convert(polygons), : argument "in_field" is missing, with no default

lawn_data

> lawn_data %>% class()
[1] "list"

lawn_distance

2地点間の距離を求める

Arguments

  • from
  • to
  • units
  • lint
> from <- '{
+  "type": "Feature",
+  "properties": {},
+  "geometry": {
+    "type": "Point",
+    "coordinates": [-75.343, 39.984]
+  }
+ }'
> to <- '{
+   "type": "Feature",
+   "properties": {},
+   "geometry": {
+     "type": "Point",
+     "coordinates": [-75.534, 39.123]
+   }
+ }'
> lawn_distance(from, to)
[1] 97.15958

lawn_point

ポイントデータの作成

> c(-74.5, 40) %>% lawn_point()
<Point>
  Bounding box: -74.5 40.0 -74.5 40.0
  Coordinates: -74.5 40.0
  Properties: NULL

lawn_polygon

ポリゴンデータの作成

> list(list(
+   c(-2.275543, 53.464547),
+   c(-2.275543, 53.489271),
+   c(-2.215118, 53.489271),
+   c(-2.215118, 53.464547),
+   c(-2.275543, 53.464547)
+ )) %>% lawn_polygon()
<Polygon>
  Bounding box: -2.3 53.5 -2.2 53.5
  No. points: 5
  Properties: NULL

lawn_random

無作為なポイントデータを生成

> lawn_random(n = 2)
<FeatureCollection>
  Bounding box: -51.9 73.5 -2.6 80.1
  No. features: 2
  No. points: 4
  Properties: NULL

view

leafletを使った可視化

> view(lawn_data$points_average)