当前位置: 首页>>代码示例>>Python>>正文


Python VRT.transform_points方法代码示例

本文整理汇总了Python中nansat.vrt.VRT.transform_points方法的典型用法代码示例。如果您正苦于以下问题:Python VRT.transform_points方法的具体用法?Python VRT.transform_points怎么用?Python VRT.transform_points使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nansat.vrt.VRT的用法示例。


在下文中一共展示了VRT.transform_points方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Domain

# 需要导入模块: from nansat.vrt import VRT [as 别名]
# 或者: from nansat.vrt.VRT import transform_points [as 别名]

#.........这里部分代码省略.........

    def get_geolocation_grids(self, stepSize=1):
        '''Get longitude and latitude grids representing the full data grid

        If GEOLOCATION is not present in the self.vrt.dataset then grids
        are generated by converting pixel/line of each pixel into lat/lon
        If GEOLOCATION is present in the self.vrt.dataset then grids are read
        from the geolocation bands.

        Parameters
        -----------
        stepSize : int
            Reduction factor if output is desired on a reduced grid size

        Returns
        --------
        longitude : numpy array
            grid with longitudes
        latitude : numpy array
            grid with latitudes
        '''

        X = range(0, self.vrt.dataset.RasterXSize, stepSize)
        Y = range(0, self.vrt.dataset.RasterYSize, stepSize)
        Xm, Ym = np.meshgrid(X, Y)

        if len(self.vrt.geolocationArray.d) > 0:
            # if the vrt dataset has geolocationArray
            # read lon,lat grids from geolocationArray
            lon, lat = self.vrt.geolocationArray.get_geolocation_grids()
            longitude, latitude = lon[Ym, Xm], lat[Ym, Xm]
        else:
            # generate lon,lat grids using GDAL Transformer
            lonVec, latVec = self.transform_points(Xm.flatten(), Ym.flatten())
            longitude = lonVec.reshape(Xm.shape)
            latitude = latVec.reshape(Xm.shape)

        return longitude, latitude

    def _convert_extentDic(self, dstSRS, extentDic):
        '''Convert -lle option (lat/lon) to -te (proper coordinate system)

        Source SRS from LAT/LON projection and target SRS from dstWKT.
        Create osr.CoordinateTransformation based on these SRSs and
        convert given values in degrees to the destination coordinate
        system given by WKT.
        Add key 'te' and the converted values into the extentDic.

        Parameters
        -----------
        dstSRS : NSR
            Destination Spatial Reference
        extentDic : dictionary
            dictionary with 'lle' key

        Returns
        --------
        extentDic : dictionary
            input dictionary + 'te' key and its values

        '''
        coorTrans = osr.CoordinateTransformation(NSR(), dstSRS)

        # convert lat/lon given by 'lle' to the target coordinate system and
        # add key 'te' and the converted values to extentDic
        x1, y1, z1 = coorTrans.TransformPoint(extentDic['lle'][0],
开发者ID:WYC19910220,项目名称:nansat,代码行数:70,代码来源:domain.py


注:本文中的nansat.vrt.VRT.transform_points方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。