0

Just want to know, is it possible to restrict the output parameters while using ogrinfo? For example, I need only the Projection details for a bunch of tab files, that too in a single continuous line and not the other details like Field_name etc. -nocount -nomd -noextent are not working. I find it very difficult to reformat the output csv file.

Currently I'am using this code List the tab/shp files properties within folders/sub folders w.r.t relative folder path to extract the information

bumped to the homepage by Community 20 hours ago

This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.

  • have you tried -so – nmtoken Apr 26 '16 at 13:17
  • yep. It's listing the file name alone – joseph_k Apr 26 '16 at 13:23
  • Is is actually listing a layer name alone. Use -al -so (all layers, summary only). However, it does list the attribute schema that you are not interested in so it is not your command. – user30184 Apr 26 '16 at 13:39
0

I believe you should rather write that -nocount, -nomd, or -noextent do not do what you would like to achieve than to say that they do not work.

If you are especially interested in projection info you might be satisfied with gdalsrsinfo http://www.gdal.org/gdalsrsinfo.html. Option -o prints projection in all supported formats. One liner you can get with out_type proj4 or mapinfo, but XML might be also good for parsing. Example follows.

gdalsrsinfo states.shp -o all

PROJ.4 : '+proj=longlat +datum=WGS84 +no_defs '

OGC WKT :
GEOGCS["GCS_WGS_1984",
    DATUM["WGS_1984",
        SPHEROID["WGS_84",6378137,298.257223563]],
    PRIMEM["Greenwich",0],
    UNIT["Degree",0.017453292519943295]]

OGC WKT (simple) :
GEOGCS["GCS_WGS_1984",
    DATUM["WGS_1984",
        SPHEROID["WGS_84",6378137,298.257223563]],
    PRIMEM["Greenwich",0],
    UNIT["Degree",0.017453292519943295]]

OGC WKT (no CT) :
GEOGCS["GCS_WGS_1984",
    DATUM["WGS_1984",
        SPHEROID["WGS_84",6378137,298.257223563]],
    PRIMEM["Greenwich",0],
    UNIT["Degree",0.017453292519943295]]

ESRI WKT :
GEOGCS["GCS_WGS_1984",
    DATUM["D_WGS_1984",
        SPHEROID["WGS_1984",6378137,298.257223563]],
    PRIMEM["Greenwich",0],
    UNIT["Degree",0.017453292519943295]]

MAPINFO : 'Earth Projection 1, 104'

XML :
<gml:GeographicCRS gml:id="ogrcrs1">
  <gml:srsName>GCS_WGS_1984</gml:srsName>
  <gml:usesEllipsoidalCS>
    <gml:EllipsoidalCS gml:id="ogrcrs2">
      <gml:csName>ellipsoidal</gml:csName>
      <gml:csID>
        <gml:name codeSpace="urn:ogc:def:cs:EPSG::">6402</gml:name>
      </gml:csID>
      <gml:usesAxis>
        <gml:CoordinateSystemAxis gml:id="ogrcrs3" gml:uom="urn:ogc:def:uom:EPSG
::9102">
          <gml:name>Geodetic latitude</gml:name>
          <gml:axisID>
            <gml:name codeSpace="urn:ogc:def:axis:EPSG::">9901</gml:name>
          </gml:axisID>
          <gml:axisAbbrev>Lat</gml:axisAbbrev>
          <gml:axisDirection>north</gml:axisDirection>
        </gml:CoordinateSystemAxis>
      </gml:usesAxis>
      <gml:usesAxis>
        <gml:CoordinateSystemAxis gml:id="ogrcrs4" gml:uom="urn:ogc:def:uom:EPSG
::9102">
          <gml:name>Geodetic longitude</gml:name>
          <gml:axisID>
            <gml:name codeSpace="urn:ogc:def:axis:EPSG::">9902</gml:name>
          </gml:axisID>
          <gml:axisAbbrev>Lon</gml:axisAbbrev>
          <gml:axisDirection>east</gml:axisDirection>
        </gml:CoordinateSystemAxis>
      </gml:usesAxis>
    </gml:EllipsoidalCS>
  </gml:usesEllipsoidalCS>
  <gml:usesGeodeticDatum>
    <gml:GeodeticDatum gml:id="ogrcrs5">
      <gml:datumName>WGS_1984</gml:datumName>
      <gml:usesPrimeMeridian>
        <gml:PrimeMeridian gml:id="ogrcrs6">
          <gml:meridianName>Greenwich</gml:meridianName>
          <gml:greenwichLongitude>
            <gml:angle uom="urn:ogc:def:uom:EPSG::9102">0</gml:angle>
          </gml:greenwichLongitude>
        </gml:PrimeMeridian>
      </gml:usesPrimeMeridian>
      <gml:usesEllipsoid>
        <gml:Ellipsoid gml:id="ogrcrs7">
          <gml:ellipsoidName>WGS_84</gml:ellipsoidName>
          <gml:semiMajorAxis uom="urn:ogc:def:uom:EPSG::9001">6378137</gml:semiM
ajorAxis>
          <gml:secondDefiningParameter>
            <gml:inverseFlattening uom="urn:ogc:def:uom:EPSG::9201">298.25722356
3</gml:inverseFlattening>
          </gml:secondDefiningParameter>
        </gml:Ellipsoid>
      </gml:usesEllipsoid>
    </gml:GeodeticDatum>
  </gml:usesGeodeticDatum>
</gml:GeographicCRS>
  • For some files i've to extract Feature_count also. And the problem with gdalsrsinfo is the layer names were listed in the output. – joseph_k Apr 26 '16 at 14:14
  • At least with GDAL 2.1-dev this command prints only one row and nothing else gdalsrsinfo test.shp -o proj4. But if ogrinfo and/or gdalsrsinfo do not give the result that you want I believe that the standard answer from GDAL folks would be "Make a Python script". – user30184 Apr 26 '16 at 14:52
  • We have to extract the details mostly for tab files. That too, very old tab files. That might be the reason i guess – joseph_k Apr 26 '16 at 15:09
  • Similar output for me gdalsrsinfo -o proj4 test.tab '+proj=utm +zone=35 +ellps=GRS80 +towgs84=0,0,0,0,0,0,0 +units=m +no_defs' – user30184 Apr 26 '16 at 15:11
  • Great. But how to identify the datum with this one ? As you said, have to work around with python script i guess – joseph_k Apr 26 '16 at 15:15

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.