1

I am using current gdal docker image osgeo/gdal:ubuntu-full-3.4.1 to display metadata from a shapefile. After multiple failed attempts of failed installation of GDAL 3.4 on Ubuntu 20.10 I am now using the docker version.

ogr2ogr has the same problem, ogrinfo failes with the following;

❯ docker run osgeo/gdal:ubuntu-full-3.4.1 ogrinfo -al myShapefile.shp
FAILURE:
Unable to open datasource `myShapefile.shp' with the following drivers.
  -> ESRIC
  -> FITS
  -> PCIDSK
  -> netCDF
  -> PDS4
  -> VICAR
  -> JP2OpenJPEG
  -> PDF
  -> MBTiles
  -> BAG
  -> EEDA
  -> OGCAPI
  -> ESRI Shapefile
  -> MapInfo File
  -> UK .NTF
  -> LVBAG
  -> OGR_SDTS
  -> S57
  -> DGN
  -> OGR_VRT
  -> REC
  -> Memory
  -> CSV
  -> NAS
  -> GML
  -> GPX
  -> LIBKML
  -> KML
  -> GeoJSON
  -> GeoJSONSeq
  -> ESRIJSON
  -> TopoJSON
  -> Interlis 1
  -> Interlis 2
  -> OGR_GMT
  -> GPKG
  -> SQLite
  -> OGR_DODS
  -> ODBC
  -> WAsP
  -> MDB
  -> PGeo
  -> MSSQLSpatial
  -> OGR_OGDI
  -> PostgreSQL
  -> MySQL
  -> OpenFileGDB
  -> DXF
  -> CAD
  -> FlatGeobuf
  -> Geoconcept
  -> GeoRSS
  -> GPSTrackMaker
  -> VFK
  -> PGDUMP
  -> OSM
  -> GPSBabel
  -> OGR_PDS
  -> WFS
  -> OAPIF
  -> SOSI
  -> Geomedia
  -> EDIGEO
  -> SVG
  -> CouchDB
  -> Cloudant
  -> Idrisi
  -> ARCGEN
  -> XLS
  -> ODS
  -> XLSX
  -> Elasticsearch
  -> Walk
  -> Carto
  -> AmigoCloud
  -> SXF
  -> Selafin
  -> JML
  -> PLSCENES
  -> CSW
  -> MongoDBv3
  -> VDV
  -> GMLAS
  -> MVT
  -> NGW
  -> MapML
  -> TIGER
  -> AVCBin
  -> AVCE00
  -> HTTP

The file is of course present, valid and not read protected. Running with sudo makes no difference. Also specifying a full-path does nothing.

5
  • Are the other "files" of the shapefile also available?
    – Mintx
    Jan 12, 2022 at 21:58
  • Yes, all of them - 7 in total. Maybe docker can't read/mount my filesystem? Jan 12, 2022 at 22:02
  • 1
    Ohh stupid me. Of course you need to mount your dir to the docker container, otherwise it won't be available. Use flag -v yourDataDir:DataDirOnContainer when running docker run. I will post a full answer tomorrow. Jan 12, 2022 at 22:23
  • 1
    Ubuntu 20.10 went end-of-life in July 2021, I'm not surprised you had trouble installing something. Docker is way overkill to get GDAL working, conda envs are simpler.
    – user2856
    Jan 12, 2022 at 23:21
  • Ah damn. Ok, I will have a try with that. Jan 12, 2022 at 23:38

1 Answer 1

3

Mount your directory to the docker container

...Of course you need to do that. Otherwise the docker container won't contain any contents and the file myShapefile.shp is just not present and the command fails.

Use the -v flag to mount a [local directory]:[container directory]. Full command;

docker run --rm -v /home/user/data:/data osgeo/gdal:ubuntu-full-3.4.1 ogr2ogr -f GeoJSON /data/myShapefile.geojson /data/myShapefile.shp

Also see the Docs - Start a container with a volume

When done your current user probably won't have permissions to access the produced file as it was created by the docker-user.

To change the file owner use sudo chown [your username] [file.shp]

To give your user read & write permissions use sudo chmod +644 [file.shp]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.