1

I am using ogr2ogr to create a geojson file with props from sqlite Db with this ogr2ogr -f GeoJSON -sql "SELECT * FROM censusblockgroups2 shp INNER JOIN 'output-z' csv ON csv.name = shp.censusblockgroup" joined_output.geojson myjoindb.db

It will create a geojson with this structure

{
"type": "FeatureCollection",
"name": "SELECT",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "id": 1, "attr": "ipsum" }, "geometry": { "type": "Point", "coordinates": [ -78.653, 35.7874 ] } },
{ "type": "Feature", "properties": { "id": 2, "attr": "lorem" }, "geometry": { "type": "Point", "coordinates": [ -78.6298, 35.7873 ] } },
{ "type": "Feature", "properties": { "id": 3, "attr": "ipsum" }, "geometry": { "type": "Point", "coordinates": [ -78.6408, 35.7795 ] } }
]
}

But is it possible to create a prefix for properties name depending on SQL table name? like "properties": { "id": 3, "output-z_attr": "ipsum" } or by alias name "properties": { "id": 3, "csv_attr": "ipsum" } or even like "properties": { "id": 3, "csv": {"name":"ipsum", other props from table} }

1
  • 1
    Easiest is to rewrite SQL select attr AS csv_attr, attr_2 AS csv_attr2.... Unfortunately the ease of select * is lost.
    – user30184
    Sep 18, 2020 at 6:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.