I am working with GeoJSON files and need to store them in PostgreSQL using perl. I can do this in 2 steps:
open (JSON,">$path/tmp/current.json");print JSON $fullJSON;close JSON;followed by:
`/usr/bin/ogr2ogr -f "PostgreSQL" PG:"dbname=database user=datauser" "$path/tmp/current.json" -nln datatable -append`; unlink ("$path/tmp/current.json");But I was hoping for a pure perl solution, without using the ogr2ogr executable. I was reading about Geo::GDAL, but not sure if this is the right tool.
I was experimenting a bit with some code I found:
my $sth = $dbh->prepare("INSERT INTO datatable (geom) VALUES (GeomFromEWKT('SRID=?;POINT(? ? ?)'));")But couldn't quite get the syntax right. The whole JSON string is: $fullJSON
If anyone has any info or code to perform this task, I'd love to see it. It seems pretty straight forward.
أكثر...
open (JSON,">$path/tmp/current.json");print JSON $fullJSON;close JSON;followed by:
`/usr/bin/ogr2ogr -f "PostgreSQL" PG:"dbname=database user=datauser" "$path/tmp/current.json" -nln datatable -append`; unlink ("$path/tmp/current.json");But I was hoping for a pure perl solution, without using the ogr2ogr executable. I was reading about Geo::GDAL, but not sure if this is the right tool.
I was experimenting a bit with some code I found:
my $sth = $dbh->prepare("INSERT INTO datatable (geom) VALUES (GeomFromEWKT('SRID=?;POINT(? ? ?)'));")But couldn't quite get the syntax right. The whole JSON string is: $fullJSON
If anyone has any info or code to perform this task, I'd love to see it. It seems pretty straight forward.
أكثر...