Closed eric-g-97477 closed 1 year ago
I suspect that the file you ran through mapshaper (ne_10m_admin_0_map_units.geo.json
) has no data properties. I can't confirm that, because the zip file you provided above contains a Shapefile, not a GeoJSON file named ne_10m_admin_0_map_units.geo.json
.
When a layer is missing attribute data, mapshaper exports it as a GeoJSON GeometryCollection (rather than as a FeatureCollection, which is probably what geopandas expects). You can tell mapshaper to use a FeatureCollection by adding a parameter to the -o
command, like this: -o geojson-type=FeatureCollection
Playing around with it more, I believe the reason is that during the simplification process, some of the features were simplified out of existence. When I added keep-shapes to the command, the output mapshaper produced was correct.
I do believe there is a bug here because mapshaper should not be outputting bad data.
The shape file I pointed to is trivial to convert to json using geopandas.
shapefile = geopandas.read_file( shapeFilePath )
shapefile.to_file( outPath, driver="GeoJSON" )
I see... my hunch was based on the error message that you pasted, which seemed to be related to the "GeometryCollection" GeoJSON type...
Mapshaper does not remove features that have null geometries post-simplification. I don't consider null-geometry features to be "bad data" -- they are valid GeoJSON according to the spec (see https://datatracker.ietf.org/doc/html/rfc7946#section-3.2 ). If you need to remove the null geometries, you can use the mapshaper command -filter remove-empty
.
That make sense. Thank you for the clarification.
I am using
Admin 0 – Details > map units
10m NaturalEarthData ( file )I figure there is a multitude of tools out there that would do the job.
I ran a couple of the commands mentioned in the documentation and geopandas was unable to load the simplified data successfully. It can load the original data without issue.
The commands were:
The geopandas code was:
and geopandas generated the error:
Is this a bug in mapshaper? Is there a correct way I should be using mapshaper? Is there a problem with the NaturalEarthData?