Export a shape file in laravel from PostgreSQL database

Viewed 19

I like to generate shape files from tables by clicking on buttons in my Laravel project.

I have a PostgreSQL/Postgis database with a table with geometry (Point) informations. Now I like to export this table as a shape file in Laravel. Until now I exported an Excel file and added it as new layer into a GIS project. Much more elegante would be a shape file directly.

Has anybody already experience within, how generate shape files in Laravel and could help me how to handle it?

I like to execute pgsql2shp and try to use Symfony\Component\Process\Process.

$command = new Process(['pgsql2shp -f '.storage_path('/app/public/shapes').' -h localhost -u postgres -P secret database1 "SELECT * FROM constructions WHERE commune_id ="'.$commune]);

$command->run();

I get only a blank page without error message.

Adding following lines

if (!$process->isSuccessful()) {
    throw new ProcessFailedException($process);
}

gives me an empty message. The SQL is correct and gives me back the right data.

What is wrong?

0 Answers
Related