[gdal-dev] gdal-dev Digest, Vol 203, Issue 38

Peter P pepanpeter at gmail.com
Wed Apr 21 02:38:15 PDT 2021


>
>
> Send gdal-dev mailing list submissions to
>         gdal-dev at lists.osgeo.org
>
> To subscribe or unsubscribe via the World Wide Web, visit
>         https://lists.osgeo.org/mailman/listinfo/gdal-dev
> or, via email, send a message with subject or body 'help' to
>         gdal-dev-request at lists.osgeo.org
>
> You can reach the person managing the list at
>         gdal-dev-owner at lists.osgeo.org
>
> When replying, please edit your Subject line so it is more specific
> than "Re: Contents of gdal-dev digest..."
>
>
> Today's Topics:
>
>    1. Re: GDAL question (Peter P)
>
> ----------------------------------------------------------------------
>
> Message: 1
>

PostgreSQL "table1" columns:
Name Data Type
Id integer
Name text
TestGeometry geometry

Example geojson - this will be one row in table:
jsonVariable = {"type": "FeatureCollection", "Name": "testName",
"features": [{"type": "Feature", "geometry": {"type": "Polygon",
"coordinates":
[[[26.54296875,64.73664139557683],[26.630859375,63.6267446447533],[29.091796875,63.97596090918338],[26.54296875,64.73664139557683]]]}}]}

Example python
ogr2ogr.main(["", "-f", "PostgreSQL", "-s_srs", "+proj=longlat +datum=WGS84
+no_defs", "-t_srs", "EPSG:3857", "PG:dbname='test' host='127.0.0.1'
port='5432' user='user1' password='password1'", "-nln", "table1",
"-append", json.dumps(jsonVariable)])


> <quote author="jratike80">
> Hi,
>
> Ogr2ogr by default converts all the columns so you should not need to do
> anything. Test first ogr2ogr from the command line without mixing Python
> into the soup. If you still do not get your "name" attribute converted you
> may have something special in your data, like a few first features in the
> GeoJSON missing the name attribute.
>
> Do you really mean "wkt_geometry" or is it possibly "wkb_geometry"?
>
> If you will still have troubles please share some test data.
>
> -Jukka Rahkonen-
>
>
>
> Peter P wrote
> > Hello
> >
> > I use GDAL(https://github.com/OSGeo/gdal) with python bindings. I am
> > importing GeoJSON to PostgreSQL (PostGIS). I know how to import only
> > geometry to the table. I dont know how to import geometry with others
> > columns to one table. I need to import geometry to "wkt_geometry" column
> > and his name to "name" column.
> > Can you help me please?
> >
> > Here is how I import only geometry column:
> > * ogr2ogr.main(["", "-f", "PostgreSQL", "-s_srs", * *"+proj=longlat
> > +datum=WGS84 +no_defs", "-t_srs", "EPSG:3857", "PG:dbname='test'
> > host='127.0.0.1' port='5432' user='user1' password='password1'", "-nln",
> > "table1"])*
> >
> > Thanks
> >
> > Best Regards
> > Peter
> >
> > _______________________________________________
> > gdal-dev mailing list
>
> > gdal-dev at .osgeo
>
> > https://lists.osgeo.org/mailman/listinfo/gdal-dev
>
>
>
>
>
> --
> Sent from: http://osgeo-org.1560.x6.nabble.com/GDAL-Dev-f3742093.html
> _______________________________________________
> gdal-dev mailing list
> <email>gdal-dev at .osgeo</email>
> https://lists.osgeo.org/mailman/listinfo/gdal-dev
> </quote>
>
> End of gdal-dev Digest, Vol 203, Issue 38
> *****************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/gdal-dev/attachments/20210421/ea8b1889/attachment-0001.html>


More information about the gdal-dev mailing list