vendredi 27 mars 2015

Load a shape file in postgresql DB with php


I am trying to load a shapefile in a postgis database using the exec() command. I have read the format I have to follow from here and I checked several similar questions from the forum.


Based on the above I wrote this script:



$command = 'shp2pgsql -s 2100 -d /home/enomix/www/EsoterikoFinal/Maps/shps/nodes.shp | psql -h localhost -p 5432 -d shapeDb -U postgres -W xxx'; $output = exec($command); print_r($output);



What I want is to load the shape file into a newly created table which is in a database called 'shapeDb'. Every time I load a shape file I want the previous table to be dropped and a new table to be created (that's why I use the -d option). I have defined a full path for my shape file (should I define a relative one like: "shps/nodes"?)


When I run the script I get nothing back as a response although I have a:



ini_set('display_errors', 1);


Its the first time I do something like this. Any idea what I am doing wrong? Thank you.





Aucun commentaire:

Enregistrer un commentaire