Reputation: 81
I want to convert a .shp file to .geojson format using ogr2ogr, which I can do from the (linux) command line. However, rather than a command line conversion, I want to invoke the conversion from a php script (using e.g. exec(..) ) and send the output directly to a variable (as a character string) instead of writing to a file. Is this possible?
Upvotes: 0
Views: 857
Reputation: 706
You can use shell_exec() method available in PHP.
public function shptogeojson($shpfilepath,$output,$srsno,$srsold){
$query="ogr2ogr -f GeoJSON -t_srs EPSG:$srsno -s_srs EPSG:$srsold $output.shp $shpfilepath";
shell_exec($query);
}
Upvotes: 1