I am new to both PostgreSQL and GeoJson. While following some of the tutorials online and some answer over here I wrote this line to import my geojson file:
ogr2ogr -f "PostgreSQL" PG:"dbname=In user=postgres" "C:\Users\hp\Downloads\red\map.geojson" -nln locations -append
But this line produces a syntax errorERROR: syntax error at or near "ogr2ogr"
I also followed the instructions on this answer Store GeoJson with Feature Collection
The data is shown but only on running the query given in the answer above. But how do I store this data. I am not able to find it by doing select * from table _name. Also the answer given on the above link shows data as expected but It is only shown the data and not storing it.
If anyone can help me insert the geojson file either by using the ogr2ogr or by helping me to insert data in table by using the link above.
-
Where did you type your command? It is a shell command, use cmd or powershell window. Donot forget to install gdal/ogr utilities.Zoltan– Zoltan2018年02月12日 07:07:37 +00:00Commented Feb 12, 2018 at 7:07
-
i am running it in cmd. Also, Do I need to run it in postgresql env or jusr in cmd(if postgre is added to path variables)Raghav Patnecha– Raghav Patnecha2018年02月12日 08:14:04 +00:00Commented Feb 12, 2018 at 8:14
-
1if you installed PostgreSQL/PostGIS via EnterpriseDB or BigSQL distributions, GDAL should have come shipped with the installation. you should find the ogr2ogr.exe in ./path/to/postgres/PostgreSQL/<your_version>/bin if I'm not mistaken (not 100% sure, you might need to search the installation path). see if you can execute your command in a cmd from within that folder containing the .exe. this folder needs to be added to PATH for windows to find it.geozelot– geozelot2018年02月12日 10:17:04 +00:00Commented Feb 12, 2018 at 10:17