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


Python VRT.reproject_GCPs方法代码示例

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


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

示例1: Domain

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

#.........这里部分代码省略.........
        continetsColor : string or any matplotlib color representation
            'coral', color of continets
        meridians : int
            10, number of meridians to draw
        parallels : int
            10, number of parallels to draw
        pColor : string or any matplotlib color representation
            'r', color of the Domain patch
        pLine : string or any matplotlib color representation
            'k', color of the Domain outline
        pAlpha : float 0 - 1
            0.5, transparency of Domain patch
        padding : float
            0., width of white padding around the map
        merLabels : list of 4 booleans
            where to put meridian labels, see also Basemap.drawmeridians()
        parLables : list of 4 booleans
            where to put parallel labels, see also Basemap.drawparallels()

        '''
        # if lat/lon vectors are not given as input
        if lonVec is None or latVec is None or len(lonVec) != len(latVec):
            try:
                # get lon/lat from Domain/Nansat object
                lonVec, latVec = self.get_border()
            except:
                print('Domain/Nansat object is not given'
                      'and lat/lon vectors=None')
                return

        # convert vectors to numpy arrays
        lonVec = np.array(lonVec)
        latVec = np.array(latVec)

        # estimate mean/min/max values of lat/lon of the shown area
        # (real lat min max +/- latBorder) and (real lon min max +/- lonBorder)
        minLon = max(-180, lonVec.min() - lonBorder)
        maxLon = min(180, lonVec.max() + lonBorder)
        minLat = max(-90, latVec.min() - latBorder)
        maxLat = min(90, latVec.max() + latBorder)
        meanLon = lonVec.mean()
        meanLat = latVec.mean()

        # generate template map (can be also tmerc)
        plt.figure(num=1, figsize=figureSize, dpi=dpi)
        bmap = Basemap(projection=projection,
                       lat_0=meanLat, lon_0=meanLon,
                       llcrnrlon=minLon, llcrnrlat=minLat,
                       urcrnrlon=maxLon, urcrnrlat=maxLat,
                       resolution=resolution)

        # add content: coastline, continents, meridians, parallels
        bmap.drawcoastlines()
        bmap.fillcontinents(color=continetsColor)
        bmap.drawmeridians(np.linspace(minLon, maxLon, meridians))
        bmap.drawparallels(np.linspace(minLat, maxLat, parallels))

        # convert input lat/lon vectors to arrays of vectors with one row
        # if only one vector was given
        if len(lonVec.shape) == 1:
            lonVec = lonVec.reshape(1, lonVec.shape[0])
            latVec = latVec.reshape(1, latVec.shape[0])

        for lonSubVec, latSubVec in zip(lonVec, latVec):
            # convert lat/lons to map units
            mapX, mapY = bmap(list(lonSubVec.flat), list(latSubVec.flat))

            # from x/y vectors create a Patch to be added to map
            boundary = Polygon(zip(mapX, mapY),
                               alpha=pAlpha, ec=pLine, fc=pColor)

            # add patch to the map
            plt.gca().add_patch(boundary)
            plt.gca().set_aspect('auto')

        # save figure and close
        plt.savefig(outputFileName, bbox_inches='tight',
                    dpi=dpi, pad_inches=padding)
        if pltshow:
            plt.show()
        else:
            plt.close('all')

    def reproject_GCPs(self, srsString):
        '''Reproject all GCPs to a new spatial reference system

        Necessary before warping an image if the given GCPs
        are in a coordinate system which has a singularity
        in (or near) the destination area (e.g. poles for lonlat GCPs)

        Parameters
        ----------
        srsString : string
            SRS given as Proj4 string

        Modifies
        --------
            Reprojects all GCPs to new SRS and updates GCPProjection
        '''
        self.vrt.reproject_GCPs(srsString)
开发者ID:WYC19910220,项目名称:nansat,代码行数:104,代码来源:domain.py


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