Socket
Book a DemoInstallSign in
Socket

turf-ruby

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

turf-ruby

1.1.0
bundlerRubygems
Version published
Maintainers
1
Created
Source

turf-ruby

Gem Version Build Status

Ruby port of Turf.js, an advance geospatial analysis library.

Installation

Add this line to your application's Gemfile:

gem 'turf-ruby'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install turf-ruby

Usage

Example:

# Turf.js uses [GeoJSON](https://en.wikipedia.org/wiki/GeoJSON) is input and output, so does turf-ruby.
from = { type: "Feature", geometry: { type: "Point", coordinates: [-75.343, 39.984] } }
to = { type: "Feature", geometry: { type: "Point", coordinates: [-75.534, 39.123] } }

Turf::distance(from, to, units: 'miles')
# 60.35329997171344

You can view all methods here: https://formigarafa.github.io/turf-ruby/. Most methods have their documentation linked to Turf.js.

Progress

Currently not all functions are available, feel free to fork the repo and port missing functions you need by reading source code of Turf.js. And don't forget to open a pull-request afterward.

This list should be updated from https://github.com/Turfjs/turf/blob/master/documentation.yml.

Measurement

  • along
  • area
  • bbox
  • bbox_polygon
  • bearing
  • center
  • center_of_mass
  • centroid
  • destination
  • distance
  • envelope
  • great_circle
  • length
  • midpoint
  • point_on_feature
  • point_to_line_distance
  • point_to_polygon_distance
  • polygon_tangents
  • rhumb_bearing
  • rhumb_destination
  • rhumb_distance
  • square

Coordinate Mutation

  • clean_coords
  • flip
  • rewind
  • round
  • truncate

Transformation

  • bbox_clip
  • bezier_spline
  • buffer
  • circle
  • clone
  • concave
  • convex
  • difference
  • dissolve
  • intersect
  • line_offset
  • polygon_smooth
  • simplify
  • tesselate
  • transform_rotate
  • transform_scale
  • transform_translate
  • union
  • voronoi

Feature Conversion

  • combine
  • explode
  • flatten
  • line_to_polygon
  • polygon_to_line
  • polygonize

Misc

  • kinks
  • line_arc
  • line_chunk
  • line_intersect
  • line_overlap
  • line_segment
  • line_slice
  • line_slice_along
  • line_split
  • mask
  • nearest_point_on_line
  • sector
  • shortest_path
  • unkink_polygon

Helper

  • feature
  • feature_collection
  • geometry_collection
  • line_string
  • multi_line_string
  • multi_point
  • multi_polygon
  • point
  • polygon

Random

  • random_line_string
  • random_point
  • random_polygon
  • random_position

Data

  • sample

Interpolation

  • interpolate
  • isobands
  • isolines
  • planepoint
  • tin

Joins

  • points_within_polygon
  • tag

Grids

  • hex_grid
  • point_grid
  • square_grid
  • triangle_grid

Classification

  • nearest_point

Aggregation

  • clusters_dbscan
  • clusters_kmeans
  • collect

Meta

  • cluster_each
  • cluster_reduce
  • coord_all
  • coord_each
  • coord_reduce
  • feature_each
  • feature_reduce
  • flatten_each
  • flatten_reduce
  • geom_each
  • geom_reduce
  • get_cluster
  • get_coord
  • get_coords
  • get_geom
  • get_type
  • prop_each
  • prop_reduce
  • segment_each
  • segment_reduce

Assertions

  • collection_of
  • contains_number
  • feature_of
  • geojson_type

Booleans

  • boolean_clockwise
  • boolean_concave
  • boolean_contains
  • boolean_crosses
  • boolean_disjoint
  • boolean_equal
  • boolean_intersects
  • boolean_overlap
  • boolean_parallel
  • boolean_point_in_polygon
  • boolean_point_on_line
  • boolean_touches
  • boolean_within

Unit Conversion

  • azimuth_to_bearing
  • bearing_to_azimuth
  • convert_area
  • convert_length
  • degrees_to_radians
  • length_to_degrees
  • length_to_radians
  • radians_to_degrees
  • radians_to_length
  • to_mercator
  • to_wgs84

Other

  • angle
  • boolean_valid
  • center_mean
  • center_median
  • directional_mean
  • distance_weight
  • ellipse
  • find_point
  • find_segment
  • geometry
  • is_number
  • is_object
  • line_each
  • line_reduce
  • line_strings
  • moran_index
  • nearest_neighbor_analysis
  • nearest_point_to_line
  • p_norm_distance
  • points
  • polygons
  • quadrat_analysis
  • rbush
  • rectangle_grid
  • standard_deviational_ellipse

Constants

  • K_TABLE
  • AREA_FACTORS
  • EARTH_RADIUS
  • FACTORS

Development

After checking out the repo, run bundle install to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/formigarafa/turf-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Turf Ruby project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.

Great Thanks

Great thanks to people that care to share and helping with the evolution of the community:

  • @layerssss - Michael Yin
  • @Henridv - Henri De Veene

FAQs

Package last updated on 25 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.