Skip to content

Instantly share code, notes, and snippets.

@januszm
Created March 15, 2018 15:00
Show Gist options
  • Save januszm/b3b72a1ff2526d1f86e4744bb92d9844 to your computer and use it in GitHub Desktop.
Save januszm/b3b72a1ff2526d1f86e4744bb92d9844 to your computer and use it in GitHub Desktop.
Convert WKB data from PostGIS to GeoJSON
result = ActiveRecord::Base.connection.execute("select * from my_shapes_table limit 1;")
shape = parser.parse result.values.first.last # .first row , .last column
RGeo::GeoJSON.encode(shape).to_json
# => "{\"type\":\"MultiPolygon\",\"coordinates\":[[[[...]]]]}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment