[gdal-dev] GDAL question
Peter P
pepanpeter at gmail.com
Wed Apr 21 02:33:19 PDT 2021
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)])
jratike80 wrote
> 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
> 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
More information about the gdal-dev
mailing list