[gdal-dev] GDAL question

Peter P pepanpeter at gmail.com
Fri Apr 23 02:54:44 PDT 2021


It is works, Thanks

Now I trying update row.
In SQL will be: /UPDATE "table1" SET "TestGeometry"=.... WHERE "Name" =
'testname'/
How is this possible in ogr2ogr? I use -update, -append not work... 


jratike80 wrote
> Hi,
> 
> Please check your GeoJSON before fighting with Python. "Name" placed into
> here
>  {"type": "FeatureCollection", "Name": "testName",
> 
> will probably be just skipped. If you used lower case "name"
> {"type": "FeatureCollection", "name": "testName",
> 
> then "testName would be used as a name of the layer.
> 
> If your aim is to use Name as an attribute place it into feature
> properties:
> 
> {"type": "FeatureCollection", "name": "LayerName", "features":
> [{"type": "Feature", 
> "properties": {"Name":"testName"},
> "geometry": {"type": "Polygon", "coordinates":
> [[[26.54296875,64.73664139557683],[26.630859375,63.6267446447533],[29.091796875,63.97596090918338],[26.54296875,64.73664139557683]]]}}]}
> 
> Test with ogrinfo:
> 
> ogrinfo name.json -al
> INFO: Open of `name.json'
>       using driver `GeoJSON' successful.
> 
> Layer name: LayerName
> Geometry: Polygon
> Feature Count: 1
> ...
> Name: String (0.0)
> OGRFeature(LayerName):0
>   Name (String) = testName
>   POLYGON ((26.54296875 64.7366413955768,26.630859375
> 63.6267446447533,29.091796875 63.9759609091834,26.54296875
> 64.7366413955768))
> 
> 
> -Jukka Rahkonen-
> 
> 
> 
> 
> Peter P wrote
>> 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)])
> 
> 
> 
> 
> 
> --
> 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