[gdal-dev] GDAL question
jratike80
jukka.rahkonen at maanmittauslaitos.fi
Wed Apr 21 03:33:20 PDT 2021
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
More information about the gdal-dev
mailing list