Saturday 31 December 2016

Storing shapefile in PostgreSQL database as a table using PHP?


I want to create a table from a shapefile in PostgreSQL. To do that, I can run this command in cmd:


shp2pgsql -s 4326 -W LATIN1 E:\Any\THA_adm public.test123 | psql -h localhost -d DATA -U postgres -w 123;

This works, but I want to run it from PHP. How can I do that, I tried PHP functions:



  1. shell_exec()


  2. exec()

  3. system()


but did not work. Is there any other way to create a table from shape in PHP or run this command?



Answer



So the answer was "by using exec() as in an example showed in the answer to question https://stackoverflow.com/questions/18259089/execute-gdal-translate-in-php-using-exec".


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...