1

我正在尝试从 gml 文件中获取投影。这是文件的顶部:

<?xml version="1.0" encoding="UTF-8"?> <eop:Mask xmlns:eop="http://www.opengis.net/eop/2.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml/3.2" gml:id="S2A_OPER_MSK_CLOUDS_SGS__20160914T145755_A006426_T31UCT_B00_MSIL1C">   <gml:name>MSK_CLOUDS pixels mask from data-strip S2A_OPER_MSK_CLOUDS_SGS__20160914T145755_A006426_T31UCT_B00_MSIL1C</gml:name> <gml:boundedBy>
    <gml:Envelope srsName="urn:ogc:def:crs:EPSG:8.7:32631">
      <gml:lowerCorner>300000 5690220</gml:lowerCorner>
      <gml:upperCorner>368340 5777580</gml:upperCorner>
    </gml:Envelope>   </gml:boundedBy>   <eop:maskMembers>
    <eop:MaskFeature gml:id="OPAQUE.0">
      <eop:maskType codeSpace="urn:gs2:S2PDGS:maskType">OPAQUE</eop:maskType>
      <eop:extentOf>
        <gml:Polygon gml:id="OPAQUE.0_Polygon">
          <gml:exterior>
            <gml:LinearRing>
              <gml:posList srsDimension="2">320340 5776020 320520 5776020 320520 5775960 320700 5775960 320700 5775900 320760 5775900 320760 5775840 320820 5775840 320820 5775660 320760 5775660 320760 5775600 320700 5775600 320700 5775540 320340 5775540 320340 5775600 320280 5775600 320280 5775660 320220 5775660 320220 5775900 320280 5775900 320280 5775960 320340 5775960 320340 5776020</gml:posList>
            </gml:LinearRing>
          </gml:exterior>
        </gml:Polygon>
      </eop:extentOf>
    </eop:MaskFeature>
...

我尝试使用来自https://pcjericks.github.io/py-gdalogr-cookbook/projection.html的代码:

from osgeo import ogr, osr
driver = ogr.GetDriverByName('ESRI Shapefile')
dataset = driver.Open(r'c:\data\yourshpfile.shp')

# from Layer
layer = dataset.GetLayer()
spatialRef = layer.GetSpatialRef()
# from Geometry
feature = layer.GetNextFeature()
geom = feature.GetGeometryRef()
spatialRef = geom.GetSpatialReference()

但是两个版本的 spatialRef 都是 None。

您可以从文件中看到,投影似乎是在边界框中给出的(在它说的第一行的最后,然后是第 2 行中带有 EPSG 代码的信封。)(它没有说'crs ' 或 'EPSG' 文件中的任何其他位置)。

谁能告诉我如何访问投影信息?

我可以以某种方式到达边界框然后得到投影吗?

4

1 回答 1

0

通常您可以在 Granules 提供的 JPEG 2000 文件中找到投影信息。

使用 gdal 它是:

gdalinfo *.jp2

给你:

PROJCS["WGS 84 / UTM zone 21N",
GEOGCS["WGS 84",
    DATUM["WGS_1984",
        SPHEROID["WGS 84",6378137,298.257223563,
            AUTHORITY["EPSG","7030"]],
        AUTHORITY["EPSG","6326"]],
    PRIMEM["Greenwich",0,
        AUTHORITY["EPSG","8901"]],
    UNIT["degree",0.0174532925199433,
        AUTHORITY["EPSG","9122"]],
    AXIS["Latitude",NORTH],
    AXIS["Longitude",EAST],
    AUTHORITY["EPSG","4326"]],
PROJECTION["Transverse_Mercator"],
PARAMETER["latitude_of_origin",0],
PARAMETER["central_meridian",-57],
PARAMETER["scale_factor",0.9996],
PARAMETER["false_easting",500000],
PARAMETER["false_northing",0],
....

那是我的全部了

于 2016-11-08T19:12:30.843 回答