openmaptiles/openmaptiles-tools

Is `shp2pgsql` missing in `openmaptiles/postgis` image?

umbertooo opened this issue · 3 comments

I'm using this article (https://openmaptiles.org/docs/generate/custom-vector-from-postgis/) to prepare custom vector tiles. My local clone of the OpenMapTiles repository is on commit 1356d724d4d077f1d9c7db037542262ebb113eef. Thus the docker-compose.yml file uses openmaptiles/postgis:5.2 as Docker image for the postgres service (instead of tag 2.3 as mentioned in the article).

On the step "Import the data into PostGIS" I set up and enter the database container

docker-compose up -d postgres
docker-compose run --rm postgres bash

Next step according to the guide is importing my ShapeFile into the database using shp2pgsql. This command is missing in the container:

# shp2pgsql --version
bash: shp2pgsql: command not found

However it exists in current postgis/postgis docker images.

Is this tool missing on purpose and how would I perform the import instead?

Looks like this is an issue (or on purpose) on the postgis image postgis/docker-postgis#206

Hi @umbertooo, there can be workaround through ogr2ogr

  1. startup a database with docker-compose up -d postgres
  2. copy your name.shp into folder data
  3. modify command where "./data/name.shp" replace with the name of the shapefile and "name" is a name of the table in PostgreSQL
docker-compose run --rm openmaptiles-tools sh -c 'ogr2ogr -f "PostgreSQL" PG:"dbname=openmaptiles user=openmaptiles password=openmaptiles host=postgres port=5432" "./data/name.shp" -s_srs EPSG:3857 -t_srs EPSG:3857 -lco OVERWRITE=YES -lco GEOMETRY_NAME=geometry -overwrite -nln "name" -nlt GEOMETRY --config PG_USE_COPY YES'

Hi @TomPohys
Thanks for looking into this so quickly. It works.