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


Python srs.SpatialReference方法代码示例

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


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

示例1: _set_srs

# 需要导入模块: from django.contrib.gis.gdal import srs [as 别名]
# 或者: from django.contrib.gis.gdal.srs import SpatialReference [as 别名]
def _set_srs(self, srs):
        "Sets the SpatialReference for this geometry."
        # Do not have to clone the `SpatialReference` object pointer because
        # when it is assigned to this `OGRGeometry` it's internal OGR
        # reference count is incremented, and will likewise be released
        # (decremented) when this geometry's destructor is called.
        if isinstance(srs, SpatialReference):
            srs_ptr = srs.ptr
        elif isinstance(srs, six.integer_types + six.string_types):
            sr = SpatialReference(srs)
            srs_ptr = sr.ptr
        elif srs is None:
            srs_ptr = None
        else:
            raise TypeError('Cannot assign spatial reference with object of type: %s' % type(srs))
        capi.assign_srs(self.ptr, srs_ptr) 
开发者ID:KimJangHyeon,项目名称:NarshaTech,代码行数:18,代码来源:geometries.py

示例2: srs

# 需要导入模块: from django.contrib.gis.gdal import srs [as 别名]
# 或者: from django.contrib.gis.gdal.srs import SpatialReference [as 别名]
def srs(self):
        "Returns the Spatial Reference used in this Layer."
        try:
            ptr = capi.get_layer_srs(self.ptr)
            return SpatialReference(srs_api.clone_srs(ptr))
        except SRSException:
            return None 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:9,代码来源:layer.py

示例3: srs

# 需要导入模块: from django.contrib.gis.gdal import srs [as 别名]
# 或者: from django.contrib.gis.gdal.srs import SpatialReference [as 别名]
def srs(self):
        """
        Returns the SpatialReference used in this GDALRaster.
        """
        try:
            wkt = capi.get_ds_projection_ref(self._ptr)
            if not wkt:
                return None
            return SpatialReference(wkt, srs_type='wkt')
        except SRSException:
            return None 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:13,代码来源:source.py

示例4: transform

# 需要导入模块: from django.contrib.gis.gdal import srs [as 别名]
# 或者: from django.contrib.gis.gdal.srs import SpatialReference [as 别名]
def transform(self, srid, driver=None, name=None, resampling='NearestNeighbour',
                  max_error=0.0):
        """
        Returns a copy of this raster reprojected into the given SRID.
        """
        # Convert the resampling algorithm name into an algorithm id
        algorithm = GDAL_RESAMPLE_ALGORITHMS[resampling]

        # Instantiate target spatial reference system
        target_srs = SpatialReference(srid)

        # Create warped virtual dataset in the target reference system
        target = capi.auto_create_warped_vrt(
            self._ptr, self.srs.wkt.encode(), target_srs.wkt.encode(),
            algorithm, max_error, c_void_p()
        )
        target = GDALRaster(target)

        # Construct the target warp dictionary from the virtual raster
        data = {
            'srid': srid,
            'width': target.width,
            'height': target.height,
            'origin': [target.origin.x, target.origin.y],
            'scale': [target.scale.x, target.scale.y],
            'skew': [target.skew.x, target.skew.y],
        }

        # Set the driver and filepath if provided
        if driver:
            data['driver'] = driver

        if name:
            data['name'] = name

        # Warp the raster into new srid
        return self.warp(data, resampling=resampling, max_error=max_error) 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:39,代码来源:source.py

示例5: _get_srs

# 需要导入模块: from django.contrib.gis.gdal import srs [as 别名]
# 或者: from django.contrib.gis.gdal.srs import SpatialReference [as 别名]
def _get_srs(self):
        "Returns the Spatial Reference for this Geometry."
        try:
            srs_ptr = capi.get_geom_srs(self.ptr)
            return SpatialReference(srs_api.clone_srs(srs_ptr))
        except SRSException:
            return None 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:9,代码来源:geometries.py

示例6: _set_srs

# 需要导入模块: from django.contrib.gis.gdal import srs [as 别名]
# 或者: from django.contrib.gis.gdal.srs import SpatialReference [as 别名]
def _set_srs(self, srs):
        "Sets the SpatialReference for this geometry."
        # Do not have to clone the `SpatialReference` object pointer because
        # when it is assigned to this `OGRGeometry` it's internal OGR
        # reference count is incremented, and will likewise be released
        # (decremented) when this geometry's destructor is called.
        if isinstance(srs, SpatialReference):
            srs_ptr = srs.ptr
        elif isinstance(srs, six.integer_types + six.string_types):
            sr = SpatialReference(srs)
            srs_ptr = sr.ptr
        else:
            raise TypeError('Cannot assign spatial reference with object of type: %s' % type(srs))
        capi.assign_srs(self.ptr, srs_ptr) 
开发者ID:ComputerSocietyUNB,项目名称:CodingDojo,代码行数:16,代码来源:geometries.py

示例7: transform

# 需要导入模块: from django.contrib.gis.gdal import srs [as 别名]
# 或者: from django.contrib.gis.gdal.srs import SpatialReference [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

示例8: transform

# 需要导入模块: from django.contrib.gis.gdal import srs [as 别名]
# 或者: from django.contrib.gis.gdal.srs import SpatialReference [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

示例9: srs

# 需要导入模块: from django.contrib.gis.gdal import srs [as 别名]
# 或者: from django.contrib.gis.gdal.srs import SpatialReference [as 别名]
def srs(self):
        """
        Returns the Spatial Reference used in this GDALRaster.
        """
        try:
            wkt = capi.get_ds_projection_ref(self.ptr)
            return SpatialReference(wkt, srs_type='wkt')
        except SRSException:
            return None 
开发者ID:0daybug,项目名称:DjangoBlog,代码行数:11,代码来源:source.py

示例10: extent

# 需要导入模块: from django.contrib.gis.gdal import srs [as 别名]
# 或者: from django.contrib.gis.gdal.srs import SpatialReference [as 别名]
def extent(self):
        "Returns the envelope as a 4-tuple, instead of as an Envelope object."
        return self.envelope.tuple

    # #### SpatialReference-related Properties ####

    # The SRS property 
开发者ID:0daybug,项目名称:DjangoBlog,代码行数:9,代码来源:geometries.py


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