Add support for GPKG file format
GPKG support would be very helpful. They are smaller than GeoJson files and support longer attribute names as shapefile.
I see that this format has some great features. And there's a JS implementation available (https://github.com/ngageoint/geopackage-js).
On the other hand, geopackage-js is a huge package. The npm install size is 140MB (mapshaper is 12MB). And the browser bundle is 5MB of minified JavaScript.
I don't want to rule out supporting GeoPackage in the future, but right now, I think Mapshaper users will have to use ogr2ogr to convert between GeoPackage and one of Mapshaper's supported formats.
No pressure as I know how much work it is maintaining OS software, but I agree this would be a great feature. Thanks as always for mapshaper!
I can't believe that the core code to read GeoPackage in geopackage-js package is that big. I quickly looked into geopackage-js package and here's definitely some other bloat code in it (like reading Shapefiles ;-). I've opened an issue over there: https://github.com/ngageoint/geopackage-js/issues/135
IMHO the best approach would be to integrate GDAL into mapshaper. This would give mapshaper access to the multitude of file formats supported by GDAL. There is a Nodejs package for GDAL: https://github.com/naturalatlas/node-gdal
Unfortunately it doesn't support GPKG for some reason: https://github.com/naturalatlas/node-gdal/issues/234
But perhaps a cooperation between the projects would be helpful.
@cgmike I like the idea of interfacing with node-gdal. As you point out, it would enable support for many file formats. It looks like the node-gdal project is not being actively maintained (incompatible with Node 12, includes an older version of GDAL, no GeoPackage support, many unanswered issues), which is too bad.
I'd like to keep the core mapshaper install relatively small... perhaps GDAL and/or GeoPackage support could be installed as add-ons.
I used node-gdal until gyp just couldn't do the binding. Have you tried https://github.com/wavded/ogr2ogr
There is now another js GeoPackage parser which generates GeoJSON:
https://loaders.gl/modules/geopackage/docs/api-reference/geopackage-loader https://github.com/visgl/loaders.gl
https://github.com/ngageoint/geopackage-js/issues/135#issuecomment-1071231493 points out that it is much smaller, about 400KB compressed, mostly due to the sql library.
Maybe worth looking into.
I like the idea of interfacing with GDAL to support more file formats. That would give us not only GeoPackage, but also KML, ESRI geodatabase (read-only) and many other widely used formats. This approach probably means that the web interface would not get GeoPackage support, undoubtedly disappointing some folks.
ogr2ogr looks like a good option (thanks @ffflabs for the suggestion), which requires that GDAL be installed separately on your system. This is probably not a problem for most users of mapshaper's command line tool -- more likely it's an advantage.
An alternative would be node-gdal-next, which uses a more recent version of GDAL than node-gdal, and includes GeoPackage support.
I just found node-gdal-async, which seems to improve on node-gdal-next.
ogr2ogr is a good option for server processing. For me the main attraction would be the browser interface. I would probably rather use ogr2ogr or gdal directly on the commandline.
FYI, you can use gdal.vectorTranslate to do something similar to ogr2ogr using node-gdal-async
See small demo at https://gist.github.com/ThomasG77/3f4795f399112c152bc9105b111e6888#file-readme-md
Hi! Just wanted to know if there are any new developments on this front. Mapshaper is so much faster and nicer to use than other alternatives but all my data is in GPKG so converting to SHP and back adds considerable overhead, often times more than the actual clip/dissolve/etc.
FWIW, I use both mapshaper and ogr2ogr on the Command Line
+1