Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Devide earth seas in multiple polygons #16

Open
kevinries opened this issue Feb 12, 2018 · 3 comments
Open

Devide earth seas in multiple polygons #16

kevinries opened this issue Feb 12, 2018 · 3 comments

Comments

@kevinries
Copy link

Hello,

Is it possible to divide the multipolygon of the oceans into several polygons? I want to save the geometries in a MongoDb, but this single object is too big to store. I did not succeed with QGIS.

@simonepri
Copy link
Owner

simonepri commented Feb 18, 2018

Hi @kevinries,

I was planning to do it.
I was just waiting for a clean way to do it using mapshaper.
You can follow the issue here.

Anyway I'll try to work on it as soon as I can.

@kevinries
Copy link
Author

That's that what I tried with QGIS. But the process took hours an at the end I got an error, because of invalid polygons. I hope, you will find a working solution.

@Isaac-Leonard
Copy link

I've got some ts code that does it using turf assuming the polygons are valid:

const removeMultiPoligons = (geojson: FeatureCollection) =>
  geojson.features.reduce((acc: Feature[], feat: Feature) => {
    const { geometry } = feat;
    switch (geometry?.type) {
      case "MultiPolygon": {
        return [
          ...acc,
          ...geometry.coordinates.map((poly) => ({
            ...feat,
            geometry: { type: "Polygon", coordinates: poly } as Geometry,
          })),
        ];
      }
      default:
        return [...acc, feat];
    }
  }, []);

Currently it won't work for some things however as its meant to work on a feature collection, it should be trivial to make it work for this data though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants