2

I know how to examine the properties of a GeoJSON file:

ogrinfo my.geojson OGRGeoJSON -so

But is there a way that I can retrieve a single feature's actual properties, to see what they look like?

I guess I can do this with head, but it would be nice if there was a structured way.

  • 1
    You should consider accepting some answers on this site occasionally. It helps keep the site clean, but also, in the case of some of your unaccepted questions, a great deal of work has gone into the answers. I would suggest that if for some reason the answer isn't what you expected, you clarify the question. 7 unaccepted answers in a row strikes me as excessive, though. – John Powell Feb 20 '17 at 16:17
7

Sure! Check the documentation for multiple options. Here are some I thought of.

Getting the first feature:

ogrinfo -al -fid 1 file.geojson

Getting the first feature via SQL:

ogrinfo -al -sql "SELECT * FROM OGRGeoJSON WHERE fid=1" file.geojson

On GDAL 2.2 you could use LIMIT like this:

ogrinfo -al -sql "SELECT * FROM OGRGeoJSON LIMIT 1" file.geojson
  • The problem with this solution is the resulting 'Layer name' is 'SELECT'? – jsta Dec 30 '17 at 15:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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