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


Python srs.CoordTransform方法代码示例

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


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

示例1: transform

# 需要导入模块: from django.contrib.gis.gdal import srs [as 别名]
# 或者: from django.contrib.gis.gdal.srs import CoordTransform [as 别名]
def transform(self, coord_trans, clone=False):
        """
        Transforms this geometry to a different spatial reference system.
        May take a CoordTransform object, a SpatialReference object, string
        WKT or PROJ.4, and/or an integer SRID.  By default nothing is returned
        and the geometry is transformed in-place.  However, if the `clone`
        keyword is set, then a transformed clone of this geometry will be
        returned.
        """
        if clone:
            klone = self.clone()
            klone.transform(coord_trans)
            return klone

        # Depending on the input type, use the appropriate OGR routine
        # to perform the transformation.
        if isinstance(coord_trans, CoordTransform):
            capi.geom_transform(self.ptr, coord_trans.ptr)
        elif isinstance(coord_trans, SpatialReference):
            capi.geom_transform_to(self.ptr, coord_trans.ptr)
        elif isinstance(coord_trans, six.integer_types + six.string_types):
            sr = SpatialReference(coord_trans)
            capi.geom_transform_to(self.ptr, sr.ptr)
        else:
            raise TypeError('Transform only accepts CoordTransform, '
                            'SpatialReference, string, and integer objects.') 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:28,代码来源:geometries.py

示例2: transform

# 需要导入模块: from django.contrib.gis.gdal import srs [as 别名]
# 或者: from django.contrib.gis.gdal.srs import CoordTransform [as 别名]
def transform(self, coord_trans, clone=False):
        """
        Transforms this geometry to a different spatial reference system.
        May take a CoordTransform object, a SpatialReference object, string
        WKT or PROJ.4, and/or an integer SRID.  By default nothing is returned
        and the geometry is transformed in-place.  However, if the `clone`
        keyword is set, then a transformed clone of this geometry will be
        returned.
        """
        if clone:
            klone = self.clone()
            klone.transform(coord_trans)
            return klone

        # Depending on the input type, use the appropriate OGR routine
        # to perform the transformation.
        if isinstance(coord_trans, CoordTransform):
            capi.geom_transform(self.ptr, coord_trans.ptr)
        elif isinstance(coord_trans, SpatialReference):
            capi.geom_transform_to(self.ptr, coord_trans.ptr)
        elif isinstance(coord_trans, six.integer_types + six.string_types):
            sr = SpatialReference(coord_trans)
            capi.geom_transform_to(self.ptr, sr.ptr)
        else:
            raise TypeError('Transform only accepts CoordTransform, '
                            'SpatialReference, string, and integer objects.')

    # #### Topology Methods #### 
开发者ID:KimJangHyeon,项目名称:NarshaTech,代码行数:30,代码来源:geometries.py

示例3: transform

# 需要导入模块: from django.contrib.gis.gdal import srs [as 别名]
# 或者: from django.contrib.gis.gdal.srs import CoordTransform [as 别名]
def transform(self, coord_trans, clone=False):
        """
        Transforms this geometry to a different spatial reference system.
        May take a CoordTransform object, a SpatialReference object, string
        WKT or PROJ.4, and/or an integer SRID.  By default nothing is returned
        and the geometry is transformed in-place.  However, if the `clone`
        keyword is set, then a transformed clone of this geometry will be
        returned.
        """
        if clone:
            klone = self.clone()
            klone.transform(coord_trans)
            return klone

        # Have to get the coordinate dimension of the original geometry
        # so it can be used to reset the transformed geometry's dimension
        # afterwards.  This is done because of GDAL bug (in versions prior
        # to 1.7) that turns geometries 3D after transformation, see:
        #  http://trac.osgeo.org/gdal/changeset/17792
        if GDAL_VERSION < (1, 7):
            orig_dim = self.coord_dim

        # Depending on the input type, use the appropriate OGR routine
        # to perform the transformation.
        if isinstance(coord_trans, CoordTransform):
            capi.geom_transform(self.ptr, coord_trans.ptr)
        elif isinstance(coord_trans, SpatialReference):
            capi.geom_transform_to(self.ptr, coord_trans.ptr)
        elif isinstance(coord_trans, six.integer_types + six.string_types):
            sr = SpatialReference(coord_trans)
            capi.geom_transform_to(self.ptr, sr.ptr)
        else:
            raise TypeError('Transform only accepts CoordTransform, '
                            'SpatialReference, string, and integer objects.')

        # Setting with original dimension, see comment above.
        if GDAL_VERSION < (1, 7):
            if isinstance(self, GeometryCollection):
                # With geometry collections have to set dimension on
                # each internal geometry reference, as the collection
                # dimension isn't affected.
                for i in xrange(len(self)):
                    internal_ptr = capi.get_geom_ref(self.ptr, i)
                    if orig_dim != capi.get_coord_dim(internal_ptr):
                        capi.set_coord_dim(internal_ptr, orig_dim)
            else:
                if self.coord_dim != orig_dim:
                    self.coord_dim = orig_dim 
开发者ID:VirtualPlants,项目名称:tissuelab,代码行数:50,代码来源:geometries.py


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