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


Python gdal.SpatialReference类代码示例

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


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

示例1: test09_authority

 def test09_authority(self):
     "Testing the authority name & code routines."
     for s in srlist:
         if hasattr(s, 'auth'):
             srs = SpatialReference(s.wkt)
             for target, tup in s.auth.items():
                 self.assertEqual(tup[0], srs.auth_name(target))
                 self.assertEqual(tup[1], srs.auth_code(target))
开发者ID:cloudera,项目名称:hue,代码行数:8,代码来源:test_srs.py

示例2: test02_bad_wkt

 def test02_bad_wkt(self):
     "Testing initialization on invalid WKT."
     for bad in bad_srlist:
         try:
             srs = SpatialReference(bad)
             srs.validate()
         except (SRSException, GDALException):
             pass
         else:
             self.fail('Should not have initialized on bad WKT "%s"!')
开发者ID:cloudera,项目名称:hue,代码行数:10,代码来源:test_srs.py

示例3: test13_attr_value

 def test13_attr_value(self):
     "Testing the attr_value() method."
     s1 = SpatialReference('WGS84')
     with self.assertRaises(TypeError):
         s1.__getitem__(0)
     with self.assertRaises(TypeError):
         s1.__getitem__(('GEOGCS', 'foo'))
     self.assertEqual('WGS 84', s1['GEOGCS'])
     self.assertEqual('WGS_1984', s1['DATUM'])
     self.assertEqual('EPSG', s1['AUTHORITY'])
     self.assertEqual(4326, int(s1['AUTHORITY', 1]))
     self.assertIsNone(s1['FOOBAR'])
开发者ID:cloudera,项目名称:hue,代码行数:12,代码来源:test_srs.py

示例4: test_unicode

    def test_unicode(self):
        wkt = (
            'PROJCS["DHDN / Soldner 39 Langschoß",'
            'GEOGCS["DHDN",DATUM["Deutsches_Hauptdreiecksnetz",'
            'SPHEROID["Bessel 1841",6377397.155,299.1528128,AUTHORITY["EPSG","7004"]],AUTHORITY["EPSG","6314"]],'
            'PRIMEM["Greenwich",0,AUTHORITY["EPSG","8901"]],'
            'UNIT["degree",0.01745329251994328,AUTHORITY["EPSG","9122"]],'
            'AUTHORITY["EPSG","4314"]],UNIT["metre",1,AUTHORITY["EPSG","9001"]],'
            'PROJECTION["Cassini_Soldner"],PARAMETER["latitude_of_origin",50.66738711],'
            'PARAMETER["central_meridian",6.28935703],PARAMETER["false_easting",0],'
            'PARAMETER["false_northing",0],AUTHORITY["mj10777.de","187939"],AXIS["x",NORTH],AXIS["y",EAST]]'
        )
        srs = SpatialReference(wkt)
        srs_list = [srs, srs.clone()]
        srs.import_wkt(wkt)

        for srs in srs_list:
            self.assertEqual(srs.name, 'DHDN / Soldner 39 Langschoß')
            self.assertEqual(srs.wkt, wkt)
            self.assertIn('Langschoß', srs.pretty_wkt)
            self.assertIn('Langschoß', srs.xml)
开发者ID:cloudera,项目名称:hue,代码行数:21,代码来源:test_srs.py

示例5: data

    def data(self):
        '''
        Read the output file and provide an iterable result
        '''
        if not hasattr(self, '_data'):
            if self.raster_obj is None:
                self._data = None
                return None
            layer = geom_extent = geom_type = spatial_ref = geom_srid = None
            # If we get here, then we have successfully determined the file type
            # that was provided, using OGR.  ogr_obj contains the OGR DataSource
            # object, and fn contains the name of the file we read to get that.

            # We only support single layer uploads, if there is more than one
            # layer then we will raise an exception
            driver = self.raster_obj.driver.name

            layer = None
            geom_extent = self.raster_obj.extent
            geom_type = 99

            srs = self.raster_obj.srs
            geos_extent = Polygon.from_bbox(self.raster_obj.extent)
            ogr_extent = geos_extent.ogr
            srid = epsg = None
            # User supplied SRID, so we will use that...
            if self._srid:
                srs = None
                geom_srid = self._srid
                epsg = str('EPSG:%s' % (geom_srid,))
                logger.debug('Setting output SRID to %s',
                             epsg)
                try:
                    srs = SpatialReference(epsg)

                    srs.validate()
                    geom_srid = srs.srid
                except Exception, e:
                    logger.debug('Invalid SRS (or none): %s', e,
                                 exc_info=True)
                    srs = None
            # No SRID! Let's try to detect it
            if srs and not geom_srid:
                if not srs.srid:
                    try:
                        srs.identify_epsg()
                        logger.debug('Auto-detect of SRID yielded %s',
                                     geom_srid)
                    except Exception as e:
                        logger.debug(
                            'SRID identification failed: %s', e,
                            exc_info=True)
                else:
                    geom_srid = srs.srid
                epsg = str('EPSG:%s' % (geom_srid,))
                logger.debug('Final SRID of file is %s', geom_srid)

            if srs and not geom_srid:
                '''
                Still no SRID - but we have an srs - so let's try to 
                reproject...
                '''
                try:
                    reprojection = CoordTransform(
                        r.srs, SpatialReference('EPSG:4326'))
                    ogr_extent.transform(reprojection)
                    geos_extent = ogr_extent.geos
                    geom_srid = geos_extent.srid
                except Exception, e:
                    if logger.isEnabledFor(logging.DEBUG):
                        logger.exception('Failed to transform: %s', e)
                    raise FormatException('Unable to determine valid SRID ' +
                                          'for this data')
开发者ID:chander,项目名称:nmtk,代码行数:73,代码来源:rasters.py


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