wavded / ogre

ogr2ogr geojson-focused web client
http://ogre.adc4gis.com
MIT License
266 stars 79 forks source link

/convert unable to convert .zip files #99

Closed macrouch closed 2 years ago

macrouch commented 2 years ago

When trying to convert previously working .zip files (with either api /convert or website) I am getting this error:

{
"error": true,
"message": "Command failed: ogr2ogr -f GeoJSON -skipfailures /vsistdout/ /vsizip//tmp/d04315b26eedc0898f5c7d68e17d3fbdATL06_shapefile_Barnes_ice_cap.zip\nFAILURE:\nUnable to open datasource `/vsizip//tmp/d04315b26eedc0898f5c7d68e17d3fbdATL06_shapefile_Barnes_ice_cap.zip' with the following drivers.\n  -> `FITS'\n  -> `PCIDSK'\n  -> `netCDF'\n  -> `PDS4'\n  -> `VICAR'\n  -> `JP2OpenJPEG'\n  -> `PDF'\n  -> `MBTiles'\n  -> `BAG'\n  -> `EEDA'\n  -> `OGCAPI'\n  -> `ESRI Shapefile'\n  -> `MapInfo File'\n  -> `UK .NTF'\n  -> `LVBAG'\n  -> `OGR_SDTS'\n  -> `S57'\n  -> `DGN'\n  -> `OGR_VRT'\n  -> `REC'\n  -> `Memory'\n  -> `BNA'\n  -> `CSV'\n  -> `NAS'\n  -> `GML'\n  -> `GPX'\n  -> `LIBKML'\n  -> `KML'\n  -> `GeoJSON'\n  -> `GeoJSONSeq'\n  -> `ESRIJSON'\n  -> `TopoJSON'\n  -> `Interlis 1'\n  -> `Interlis 2'\n  -> `OGR_GMT'\n  -> `GPKG'\n  -> `SQLite'\n  -> `OGR_DODS'\n  -> `ODBC'\n  -> `WAsP'\n  -> `PGeo'\n  -> `MSSQLSpatial'\n  -> `OGR_OGDI'\n  -> `PostgreSQL'\n  -> `MySQL'\n  -> `OpenFileGDB'\n  -> `XPlane'\n  -> `DXF'\n  -> `CAD'\n  -> `FlatGeobuf'\n  -> `Geoconcept'\n  -> `GeoRSS'\n  -> `GPSTrackMaker'\n  -> `VFK'\n  -> `PGDUMP'\n  -> `OSM'\n  -> `GPSBabel'\n  -> `SUA'\n  -> `OpenAir'\n  -> `OGR_PDS'\n  -> `WFS'\n  -> `OAPIF'\n  -> `SOSI'\n  -> `HTF'\n  -> `AeronavFAA'\n  -> `Geomedia'\n  -> `EDIGEO'\n  -> `SVG'\n  -> `CouchDB'\n  -> `Cloudant'\n  -> `Idrisi'\n  -> `ARCGEN'\n  -> `SEGUKOOA'\n  -> `SEGY'\n  -> `XLS'\n  -> `ODS'\n  -> `XLSX'\n  -> `Elasticsearch'\n  -> `Walk'\n  -> `Carto'\n  -> `AmigoCloud'\n  -> `SXF'\n  -> `Selafin'\n  -> `JML'\n  -> `PLSCENES'\n  -> `CSW'\n  -> `VDV'\n  -> `GMLAS'\n  -> `MVT'\n  -> `NGW'\n  -> `MapML'\n  -> `TIGER'\n  -> `AVCBin'\n  -> `AVCE00'\n  -> `HTTP'\n"
}

Attached is the shapefile I attempted to convert ATL06_shapefile_Barnes_ice_cap.zip

wavded commented 2 years ago

This is failing because the shapefile components (e.g. shx, shp, dbf, etc) files exist in a directory within the ZIP file and not at the root.

glims_download_01774/
glims_download_01774/glims_polygons.shx
glims_download_01774/glims_polygons.shp
glims_download_01774/CITATIONS.txt
glims_download_01774/.DS_Store
glims_download_01774/glims_polygons.dbf
glims_download_01774/glims_polygons.prj
glims_download_01774/README.txt

For ogr2ogr to understand the file type, it needs it to be at the root:

README.txt
glims_polygons.prj
glims_polygons.dbf
CITATIONS.txt
glims_polygons.shp
glims_polygons.shx

If you've noticed a change, you are correct. Before we were trying to guess where the shapefile may be inside the ZIP but now we rely solely on how the ogr2ogr finds it. Below is a working version of the ZIP I recompressed without the directory.

Archive.zip

macrouch commented 2 years ago

@wavded ah ok, thanks for explaining that! Tried your updated shapefile and it works as expected