Contents
- 1 How to import GeoJSON into PostGIS-geographic information?
- 2 How to import geopackages into Postgres / PostGIS database?
- 3 Is there a Z dimension for GeoJSON polygons?
- 4 How to bring in geometry part of GeoJSON?
- 5 Can a row be returned as a GeoJSON feature?
- 6 How to store GeoJSON featurecollection in PostgreSQL 9.3?
- 7 How to import ISO2 features in ogr2ogr?
- 8 How to insert a GeoJSON point into a JSON column?
- 9 Where can I find ogr2ogr in Fw tools?
How to import GeoJSON into PostGIS-geographic information?
You can use PostGIS’s ST_GeomFromGeoJSON to bring in just the geometry part of the GeoJSON. Better yet, you can use ogr2ogr to import the entire JSON document: ogr2ogr -f “PostgreSQL” PG:”dbname=my_database user=postgres” “source_data.json” -nln destination_table -append (I haven’t tested this with your data, add a comment if you have issues.)
How to import geopackages into Postgres / PostGIS database?
This is the command line I used: ogr2ogr -f PostgreSQL PG:”dbname=’databasename’ host=’addr’ port=’5432′ user=’x’ password=’y'” path_name\\geopackage_name.gpkg I use a server Ubuntu 18.04 LAMP with postgres/postgis and I would like to import geopackage from my PC (Ubuntu 19.10 + Qgis + Postgresql 10 + gdal library installed).
How is ogr2ogr used to convert GIS data?
Ogr2ogr is the swiss-army knife when it comes to conversion of GIS data. It is part of the Geospatial Data Abstraction Library and provides an easy way to convert data between common storage formats: GeoJSON, Shapefile, PostGIS and others.
How to import a shapefile to PostGIS with ogr2ogr?
As you discovered by trial and error, there were few nagging issues you needed to fix, the last of which was resolved using ogr2ogr’s -nlt GEOMETRY * argument.
Is there a Z dimension for GeoJSON polygons?
In my view it doesn’t seem that the geometry has a Z dimension. Taking a look at the source code of PostGIS I found out how it parses SRIDs. Here is the correct way to specify the SRID in GeoJSON. The GeoJSON specification says that the coordinates of a polygon are an array of line strings.
How to bring in geometry part of GeoJSON?
You can use PostGIS’s ST_GeomFromGeoJSON to bring in just the geometry part of the GeoJSON. ogr2ogr -f “PostgreSQL” PG:”dbname=my_database user=postgres” “source_data.json” -nln destination_table -append
How are the geometries defined in PostGIS in SQL?
In conformance with the Simple Features for SQL ( SFSQL) specification, PostGIS provides two tables to track and report on the geometry types available in a given database. The first table, spatial_ref_sys, defines all the spatial reference systems known to the database and will be described in greater detail later.
Is there a St geomfromgeojson for JSON?
ST_GeomFromGeoJSON works only for JSON Geometry fragments. It throws an error if you try to use it on a whole JSON document. Enhanced: 3.0.0 parsed geometry defaults to SRID=4326 if not specified otherwise. Enhanced: 2.5.0 can now accept json and jsonb as inputs. Availability: 2.0.0 requires – JSON-C >= 0.9
Can a row be returned as a GeoJSON feature?
Return the geometry as a GeoJSON “geometry” object, or the row as a GeoJSON “feature” object. (Cf GeoJSON specifications RFC 7946 ). 2D and 3D Geometries are both supported. GeoJSON only support SFS 1.1 geometry types (no curve support for example).
How to store GeoJSON featurecollection in PostgreSQL 9.3?
Assuming you have at least PostgreSQL version 9.3, you can use a few JSON functions and operators to extract the relevant parts of the GeoJSON specification required by ST_GeomFromGeoJSON to create geometries. Finds three geometries. The geom column has the geometry object, and the gid is the feature number.
How to assign srid to GeoJSON featurecollection?
You should assign an SRID for the geometry, using ST_SetSRID. Or if you simply need a single heterogeneous GEOMETRYCOLLECTION, you can make it compact like this:
Can a PostGIS command be used in OGR?
PostGIS is one of the supported read/write OGR formats, so it is possible to use the OGR API or any OGR commands (such as ogrinfo and ogr2ogr) to manipulate its datasets.
How to import ISO2 features in ogr2ogr?
Using some of the options from ogr2ogr, you will import only the features from SUBREGION=2 (Africa), and the ISO2 and NAME attributes, and rename the feature class to africa_countries:
How to insert a GeoJSON point into a JSON column?
The following example inserts a GeoJSON point into a JSON column and afterwards updates the geometry column with the above mentioned function. Thanks for contributing an answer to Stack Overflow!
Where can I find the GeoJSON format format?
GeoJSON format is popular among web mapping frameworks. You can test and view your GeoJSON data online on geojson.io. To build FeatureCollection: To get Features as records:
How to test PostGIS import with shp2pgsql?
I would have been stumped by your second error for awhile, but by testing your SQL user with a different import utility (shp2pgsql), which was smart, you got a more precise error message and gave your SQL user necessary privileges on the spatial_ref_sys table.
Where can I find ogr2ogr in Fw tools?
Ogr2ogr is available as part of the FW Tools Toolkit: http://fwtools.maptools.org/ . It is usually called from the command line using the following syntax: If we want to specify a destination table, we can use the -nln table option.