Questions tagged [rgeo]
RGeo is a geospatial data library for Ruby.
115
questions
0
votes
1
answer
29
views
RGeo Points not saved in ActiveRecord Postgis table (nil)
I have a Rails 6.1.4.1 app using Postgis database (Docker image: postgis/postgis:13-3.1-alpine).
I try to save geographic points in the attribute lonlat of my Branch model.
ANY attempt to save my ...
0
votes
1
answer
116
views
Issue with RGeo / GeoJSON / LinearRing failed ring test / EPSG 3857 vs EPSG: 4326
My overall goal is to answer, "Does this point intersect with this geojson object"
I am attempting to do this with the following code:
boundaries = {...} # geojson object
point = RGeo::...
2
votes
2
answers
98
views
How do I find the nearest location in a separate list of coordinates in r?
Given a list of event locations:
event.coords <- data.frame(
event.id = letters[1:5],
lats = c(43.155, 37.804, 26.71, 35.466, 40.783),
lons = c(-77.616,-122.271, -80.064, -97.513, -73....
0
votes
1
answer
56
views
Why does rgeo have CAPI and FFI factories to achieve the same goal?
If I understand the Rgeo doc & code correctly, there's CAPIFactory which is supposed to link to GEOS and there is FFIFactory using ffi-geos gem which links to GEOS using FFI.
Both of these seem to ...
0
votes
1
answer
30
views
Convert from ESPG 4326 to ESPG 3758
I am having a problem with converting geometry data in my rails application project. Currently, I am having one database storing data with SRID 4326 and I need to move it to another database that uses ...
0
votes
1
answer
158
views
Calculating area with RGeo and Geojson
I have a multi-polygon defined in geojson. I am trying to calculate its area.
When I traverse the ostensible code path, I am getting very confusing results. I suspect this is because I am using some ...
1
vote
1
answer
43
views
rgeo point near MULTILINESTRING
Having a geometry column wkb_geometry, srid 4326 that is a MULTILINESTRING I would like to determine which of these records are within a predetermined distance (say 5000m) of a geometry object POINT
...
1
vote
3
answers
512
views
RStudio graphics device really slow for spatial objects on mac
I recently got a new macbook pro and am having some R graphics related problems on it. R is working insanely slowly when plotting sf objects. I found a thread that's a couple of years old on this ...
-1
votes
1
answer
334
views
change projection on geom_sf map
I need to map the east coast of US and Canada with ggplot and geom_sf, but I want to do so with a projection that will make Florida to Nova Scotia less exaggerated from East to West, such as Lambert ...
2
votes
1
answer
182
views
RGeo::Geos.supported? shows as false even with -dev packages and symlink in place
Trying to get the rgeo gem to recognise geos on an ubuntu 16.04 system.
I have the following packages installed:-
libgeos-dev, libgeos++-dev and libgeos-3.7.1
geos-config --version
3.7.1
I have a ...
1
vote
2
answers
285
views
Is it possible to Azimuthal equidistant projection and create a buffer polygon in Ruby
I have found this code in stack overflow to do Azimuthal equidistant projection and create a buffer polygon in Python.
aeqd_proj = '+proj=aeqd +lat_0={lat} +lon_0={lon} +x_0=0 +y_0=0'
project =...
0
votes
1
answer
438
views
NameError: uninitialized constant ActiveRecord::ConnectionAdapters::PostgreSQL::ColumnDefinition with gem activerecord-postgis-adapter
I want add to an existing data base the postgis extension with rails as an environment.
I have identified the rgeo gem associated with the activerecord-postgis-adapter gem
I did the classic bundle ...
1
vote
1
answer
346
views
RGeo: How to transform a projected coordinate to lat/lon using SRID
I'd like to transform a point in projected coordinates to lat/lon.
I've read this blog post about transformations and I came up with the following code:
factory_25831 = RGeo::Cartesian.factory(:srid =...
0
votes
1
answer
156
views
Postgis is not setting up in Rails application
I am integrating PostGIS in a rails application and following their documentation https://github.com/rgeo/activerecord-postgis-adapter.
At this step
rake db:create
I get the following error.
...
0
votes
1
answer
101
views
Calculating the distance between two long/lat points in the same data.frame
For starters, here is the table structure I'm using:
df <- structure(list(customer_id = c(353808874L, 69516747L, 357032052L,
307735090L, 307767260L), id = c("8474", "8107",
"1617436", "7698", "...
0
votes
1
answer
263
views
How to do an intersection of geojson with rgeo?
I am new to ruby and experimenting with rgeo.
I have 2 geojson files:
points.geojson contains a number of points
here is a gist of points.geojson
outline.geojson contains a single polygon
here is a ...
2
votes
2
answers
1k
views
Getting InvalidGeometry: LinearRing failed ring test after upgrading rgeo gem
After upgrading the rgeo gem from 0.6.0 to 2.1.1, we've started to get 'LinearRing failed ring test' on certain geometries that never caused us problems before. (The geometry data is generated from ...
2
votes
1
answer
227
views
Rails RGeo::Geos.supported? false on rails c, but true on irb
I'm using the rgeo gem which gives me troubles on the production server, although it works on my local machine.
This outputs are same on both local MacOS and Ubuntu 16.04 production machine:
psql --...
1
vote
1
answer
337
views
Find polygons contained inside polygon using RGeo, PostGIS and ST_Contains
I have two models: Search (geom saved on attribute area) and Land (geom saved on attribute geom).
Land is imported from an external service and is saved to DB with specific SRID. EG:
SRID=28992;...
1
vote
1
answer
225
views
RGeo::Geos.supported? true in irb but false with bundler in macOS mojave
In macOS mojave gem install rgeo installs and in irb RGeo::Geos.supported? returns true
Now after doing bundle install and going to rails console via bundle exec rails c, it returns false.
How to ...
1
vote
0
answers
74
views
How to separate POLYGONS from MULTIPOLYGON in Ruby
I was checking RGeo and did not find a way to check if a provided data in a GeoJSON in MultiPolygon is a inner ring or exterior ring (I was checking this to just separate out MultiPolygon into ...
0
votes
1
answer
176
views
Calling PostGIS functions within Ruby
I need to execute the PostGIS function st_intersection within an SQL SELECT clause in Ruby. At the moment I am doing it as raw SQL query:
sql_query = "SELECT id, ST_ASEWKT(ST_INTERSECTION(geometry, ?)...
1
vote
1
answer
433
views
How to find the Closest point of a line string to a given location - rgeo
My point coordinates are in geographic coordinate systems. They are in memory. I need to find the nearest point on the line string to a given point using RGeo library from Ruby.
My scenario is the ...
2
votes
1
answer
339
views
RGeo::GeoJSON not decoding and returning geometry as_text for 'doughnut' polygon
Some geographical regions are areas that surround a major metropolitain city, where each is a distinct administrative area. This is the case of the capitals of Switzerland (de facto) and Brazil.
{"...
0
votes
1
answer
16
views
quoting error importing JSON formatted column of geographical object via CSV into rails + postgresql/postgis
data structure:
create_table "regionpolygons", force: :cascade do |t|
t.geometry "rawdata", limit: {:srid=>0, :type=>"geometry"}
A CSV import file
task :load_geometry_data => :...
0
votes
1
answer
186
views
Find record by lat / lon in rails-postgres-rgeo project
Having Table Neighborhoods, which looks like this:
id: 1,
title: "Sun City",
state: "CA",
geometry: "MULTIPOLYGON (((-117.1935499999999 33.74306900000005, -117.1935729999999 33.74198700000005, -117....
1
vote
2
answers
981
views
Rails / PostGIS / RGeo Error: NoMethodError: undefined method `factory' for RGeo::GeoJSON::Feature
I am using Ruby on Rails and PostGIS to store GeoJSON map data in a model called, "Map". When I save an object loaded successfully with a simple GeoJSON feature I get the error, "NoMethodError: ...
0
votes
1
answer
143
views
Why isn't POSTGIS / RGEO loading the right point type when reading location data from the DB?
So I'm trying to get up to speed on location based programming in Rails for a project. In summary, my database data appears to be correct, but I can't get the rails in-memory logic to get correct ...
1
vote
1
answer
462
views
Try to use Rgeo with rails
I'm a newbie on rails and tried using Rgeo and GeoJSON.
I want to extract GeoJSON from my data to use in leaflet.
What is the proper way to install GeoJSON (and/or place).
Gemfile :
gem '...
0
votes
2
answers
1k
views
Dissolve output of rasterToPolygons
When using rasterToPolygons within the raster package each cell that meets the formula criteria becomes its own polygon:
library(raster)
r <- raster(nrow=18, ncol=36)
r[] <- runif(ncell(r)) * ...
0
votes
1
answer
530
views
RGeo contains? on Model
I need to find all the instances of a class Place where its polygon attribute contains a point supplied, as in Place.for_point(pt).
==== added ====
Ok, I can get this query to execute, but with the ...
5
votes
1
answer
3k
views
RGeo - fix self-intersections
I have a bunch of polygons that have self-intersection which causes some errors in further postprocessing them (in particular - I can't calculate intersection area of those polygons with other ...
2
votes
2
answers
1k
views
Convert Polygon to MultiPolygon using RGeo gem
I have a legacy areas data, where some records are in Polygon and some in MultiPolygon format stored in noSQL DB in JSON format. I need to migrate that data to a PostGIS database with area column, ...
0
votes
1
answer
280
views
How to determine if a lat/lon pair is located inside of a shapefile polygon
I am using the rgeo and rgeo-shapefile gems in my Rails 5 application. My goal is to load in a shapefile of neighborhoods and determine which neighborhood a latitude/longitude point is located within.
...
0
votes
1
answer
818
views
What is the best way to remove duplicate points from a geojson polygon in ruby?
I am using the rgeo ruby library to parse out geojson polygons. The behavior is to return nil when calling decode on a polygon with duplicate points as in the following example:
geom = {:geom=>{"...
3
votes
3
answers
3k
views
Point in polygon rgeo
I need to know if a point is in a polygon or not, in my rails app, in order to to that I wan to use rgeo gem.
To install this geme i folowed the instructions on rgeo git
Then I'm sure that GEOS and ...
1
vote
1
answer
216
views
How to output geojson from a collection
I want to output a geojson file from my rails app using rgeo-geojson. I have a table of points each with lat and long.
I have my controller set up in the standard way
respond_to do |format|
...
4
votes
1
answer
2k
views
Simplifying polygons in rgeos and maintaining data in SpatialPolygonsDataFrame
Background
I'm interested in simplifying polygons with use of the gSimplify function available through the rgeos package.
Reproducible example
A reproducible example can be generated with use of ...
0
votes
1
answer
290
views
How to find all polygons thats includes special lat long point
I use rgeo and activerecord-postgis-adapter gem. I want to find all records where special point is included in polygon. I marked rectangular on google map and expect that sql return row if point is ...
1
vote
1
answer
903
views
I want to save GeoJSON polygon
I want to save a polygon.
This is Geojson enter link description here
str1 = "geojson....."
geom = RGeo::GeoJSON.decode(str1, json_parser: :json)
l = Limit.new
l.multipoligono = geom
l.save
...
2
votes
1
answer
370
views
How to edit GeoJSON data in rails view?
I want to have ability to edit GeoJSON data as text, in edit page. I use Rails, PostgreSQL with activerecord-postgis-adapter. For encoding data I use rgeo-geojson.
My show view works fine, I encode:
...
2
votes
2
answers
621
views
Using activerecord-postgis-adapter and point is not cast as spherical
I'm trying to create a basic app using the activerecord-postgis-adapter gem and am following the instructions in the readme.
According to the readme, a point is supposed to use the spherical factory, ...
2
votes
0
answers
103
views
ArgumentError when storing point using RGeo
I'm having some trouble storing a point in RGeo.
initializer/rgeo.rb
RGeo::ActiveRecord::SpatialFactoryStore.instance.tap do |config|
# By default, use the GEOS implementation for spatial columns.
...
5
votes
1
answer
453
views
RGeo The union of two MultyPolygons is returning nil
I want to create a new MultiPolygon from the union of two geometries, but it returns nil.
multipolygon_1 = RGeo::Geos.factory(srid: 4326).parse_wkt("MULTIPOLYGON ...")
multipolygon_2 = RGeo::Geos....
4
votes
2
answers
1k
views
Problems with RGeo intersection functions
I'm getting strange/incorrect results from RGeo polygon intersection functions (Ruby 2.3.0, RGeo 0.5.3)
EXAMPLE 1:
I have two polygons which I believe share a boundary but do not share any internal ...
2
votes
1
answer
1k
views
Storing Google Maps geo data with Rails / PostGIS / RGeo
Having trouble implementing Daniel Azuma's solution for handling Google Maps geo data with RGeo / Rails.
SETUP
locations table:
create_table "locations", force: :cascade do |t|
t.string &...
3
votes
1
answer
722
views
Installing GEOS on Heroku
I'm trying to deploy a Rails app (ruby 2.3.0, rails 4.2.6) to Heroku that uses the RGeo gem, but I'm having no luck installing the underlying GEOS library upon which the RGeo gem relies (See https://...
2
votes
1
answer
591
views
How to set up a postgis-adaptered Ruby on Rails app for Heroku deployment?
I have the following:
Gems:
gem 'pg', '~> 0.18'
gem 'activerecord-postgis-adapter', '4.0.0'
gem 'rgeo-geojson'
Initializer: config/initializers/rgeo.rb
require 'rgeo-activerecord'
RGeo::...
1
vote
0
answers
353
views
How to save google.maps.Data.MultiPolygon to geometry datatype column in postgres database in rails?
I am a beginner in rails framework, so please pardon my naive question. I have a google.maps.Data.MultiPolygon object on my frontend which I want to save in my database. The table searches creates a ...
2
votes
2
answers
1k
views
polygon 'contains' and other operations on geometries not supported
I'm quite new to postgis and rgeo. I suspect I may be tackling things in the wrong way but I have been a bit surprised to find out a few operations, in particular contains & within, aren't ...