Geovation / tiler

A no nonsense Vector Tile pipeline
MIT License
152 stars 16 forks source link

Connecting your own PostGIS database #29

Open grobins opened 6 years ago

grobins commented 6 years ago

Hi, I'm a little unclear how to read from a Postgis database. Is that a DB that's running on my localhost? I've tried setting environment variables for DB_HOST, DB_USER etc, and specifying a query in my project.tiler.json file, but it can't find these variables.

I'm trying to create tiles for 1.5million linestrings.. and having issues because my source data is in WKT in a CSV, and the only way I know to create the shapefile is with QGIS, which crashes...

JamesLMilner commented 6 years ago

Which database are you wanting to use? Tiler comes with a database inside the Docker container itself.

If you're running PostGIS on your host machine, and you want to connect to that, that should be possible. You probably need to set DB_HOST to the IP address of the host machine. See this question on StackOverflow: https://stackoverflow.com/questions/31249112/allow-docker-container-to-connect-to-a-local-host-postgres-database

Regarding creating Shapefiles, you could use ogr2ogr which is a command line tool, and a less likely to crash than QGIS.

grobins commented 6 years ago

Thanks James, I'll check that out. I guess I can just connect to the Tiler DB and put my data in there for the job... with ogr2ogr, will that be able to create a shapefile from all the rows in my source CSV?

JamesLMilner commented 6 years ago

I don't know the internals of GDAL supporting formats, but from the docs it sounds promising: http://www.gdal.org/drv_csv.html

Specifically: "When reading a field named "WKT" is assumed to contain WKT geometry, but also is treated as a regular field."