Sunday 17 June 2018

gdal - How to access Shapefile metadata using OGR?



I'm trying to use ogrinfo to get some details on a shapefile I downloaded. Currently, the only way I know how to do this is to load it into QGIS and manually click around to find any information on it, like opening the attribute table.


I just want to be able to see any metadata is tagged along with the features. If I do:


ogrinfo -al USA_adm0.shp

I can see at the beginning there is a lot of useful information, but then it flies past with all the feature data.


Can someone help me out?



This is what I get on my mac using the -ro and -so flag, doesn't seem to be much help.


->ogrinfo -ro -so USA_adm0.shp
INFO: Open of `USA_adm0.shp'

using driver `ESRI Shapefile' successful.
1: USA_adm0 (Polygon)

Answer



ogrinfo can shorten the output considerably using the -so flag.



-so: Summary Only: supress listing of features, show only the summary information like projection, schema, feature count and extents.



So ogrinfo -ro -so file.shp should give a summary of the metadata.


And




-al: List all features of all layers (used instead of having to give layer names as arguments).



Would certainly give you a lot of info on the other hand if used by itself!


And if you want to see metadata for individual or a range of features, there is the -fid, -where, and -sql flags which do that.


Lastly, -geom will act as a master toggle for the geometry info.



-geom={YES/NO/SUMMARY}: (starting with GDAL 1.6.0) If set to NO, the feature dump will not display the geometry. If set to SUMMARY, only a summary of the geometry will be displayed. If set to YES, the geometry will be reported in full OGC WKT format. Default value is YES.



There is a FAQVector Wiki with examples for GDAL command line utilities that also gives some other tips =)


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...