question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MultiPolygon Error

See original GitHub issue

I’m getting an Invalid GeoJSON error when calling st.geomFromGeoJSON on a MultiPolygon.

In a GeoJSON linter, I get the error that the GeoJSON doesn’t follow the right-hand rule, although using geojson-rewind to fix this produces no change in result.

I’m stumped here and would appreciate any insight.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jfgodoycommented, Oct 17, 2017

the function geomFromGeoJSON receives only the geometry part as argument. So if you save the geojson before as multi.json, you can execute this:

const knex = require('knex');
const knexPostgis = require('knex-postgis');
const multi = require('./multi.json');
const rewind = require('geojson-rewind');

const db = knex({
  dialect: 'postgres'
});

const st = knexPostgis(db);

// fix 'Polygons and MultiPolygons should follow the right-hand rule'
const multiFixed = rewind(multi);

const sql1 = db.insert({
  id: 1,
  geom: st.geomFromGeoJSON(multiFixed.features[0].geometry, 4326)  // geometry of the first multipolygon of the collection
}).into('mytable').toString();

console.log(sql1);
0reactions
jfgodoycommented, Oct 17, 2017

good!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Invalid MultiPolygon value even though all the Polygons are ...
I am trying to convert coordinates to WKT format. Here I have a list of polygons which should be identified as a Multi...
Read more >
Compatibility error (multipolygon - polygon) when merging two ...
When I try to merge two features - originally from two different source layers, now in the Merged layer - I get this...
Read more >
12.17.7.4 Polygon and MultiPolygon Property Functions
If the geometry is valid but is not a Polygon or MultiPolygon object, an ER_UNEXPECTED_GEOMETRY_TYPE error occurs. If the geometry is a valid...
Read more >
MultiPolygon throws error in react-map-gl-draw #457 - GitHub
Describe the bug. When supplying initial value in polygon Editor loads properly but when multipolygon is given editor throws error.
Read more >
Cast geometry to another type: either simplify, or cast explicitly
S3 method for MULTIPOLYGON st_cast(x, to, . ... 36.58965 #> Geodetic CRS: NAD27 mpl <- nc$geometry[[4]] #st_cast(x) ## error 'argument "to" is missing, ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found