3

I have a geojson feature collection. Some of its features have spaces in their property names. I am attempting to use the -select argument to limit which properties are included in the output.

Is there a way to pass in property names that have spaces in them? On Ubuntu 18.04.3 I have tried:

ogr2ogr -select '"My Property"' -f 'Esri Shapefile' my-shp-dir my-fc.json

Which results in: Error 1: Field "My not found in source layer

I have also tried not quoting the spaced properties, and putting square brackets around them.

Is there a way to handle spaces in properties?

4
  • Linux or Windows?
    – user30184
    May 19, 2020 at 20:36
  • @user30184 Ubuntu 18.04.3
    – Avocado
    May 19, 2020 at 21:10
  • Maybe '"My\ Property"'?
    – wfgeo
    May 19, 2020 at 21:24
  • @wfgeo no such luck: ERROR 1: Field '"My\' not found in source layer.
    – Avocado
    May 19, 2020 at 21:26

1 Answer 1

4

I don't think you can do it directly with select, but you can use -sql instead of -select to reference a column/property with spaces in the name:

ogr2ogr -sql 'SELECT "My Property" FROM layername' -f 'Esri Shapefile' my-shp-dir my-fc.json

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.