Esempio n. 1
0
def get_coordtransform():
	from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform
	sl = SpatialReference('EPSG:3787')
	sl.import_wkt(sl_wkt)
	wgs = SpatialReference('EPSG:4326')
	trans = CoordTransform(sl, wgs)
	return trans
Esempio n. 2
0
def get_coordtransform():
    from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform
    sl = SpatialReference('EPSG:3787')
    sl.import_wkt(sl_wkt)
    wgs = SpatialReference('EPSG:4326')
    trans = CoordTransform(sl, wgs)
    return trans
Esempio n. 3
0
def trans(p, srid):
    '''transform Point p to requested srid'''
    if not isinstance(p,Point):
        raise TypeError('django.contrib.gis.geos.Point expected')
    psrid = p.srid
    if not psrid:
        psrid = WGS84
    if (psrid != srid): 
        tr = CoordTransform(SpatialReference(p.srid), SpatialReference(srid))
        p.transform(tr)
    return p
Esempio n. 4
0
def find_coordtransform(srid):
    if srid == u'EPSG:3787':
        return get_coordtransform()
    elif srid == u'EPSG:3912':
        from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform
        sl = SpatialReference('EPSG:3912')
        wgs = SpatialReference('EPSG:4326')
        trans = CoordTransform(sl, wgs)
        return trans
    else:
        raise ValueError("Couldn't find transform: %r" % srid)
Esempio n. 5
0
    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.')
Esempio n. 6
0
 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
Esempio n. 7
0
 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
Esempio n. 8
0
 def to_python(self, value):
     value = super(SpatialReferenceField, self).to_python(value)
     if value in self.empty_values:
         return None
     try:
         return SpatialReference(value)
     except (SRSException, TypeError):
         return None
Esempio n. 9
0
    def current_location(self, hacc=10000):
        ''' returns current location '''
        from django.contrib.gis.gdal.srs import CoordTransform, SpatialReference

        s = self.survey_set.last()
        if s:
            pnt = s.location
            wgs84 = SpatialReference(4326)
            rdnew = SpatialReference(28992)
            trans = CoordTransform(rdnew, wgs84)
            pnt.transform(trans)
            return {
                'id': self.id,
                'name': self.displayname,
                'lon': pnt.x,
                'lat': pnt.y
            }
        else:
            # get location from on-board GPS
            # select only valid fixes (with hacc > 0)
            g = self.get_sensor('GPS').loramessage_set.filter(
                locationmessage__hacc__gt=0).order_by('time')
            if g:
                if hacc:
                    # filter messages on maximum hacc
                    g = g.filter(hacc__lt=hacc)

                # use last valid gps message
                g = g.last()

                if g.lon > 40 * 1e7 and g.lat < 10 * 1e7:
                    # verwisseling lon/lat?
                    t = g.lon
                    g.lon = g.lat
                    g.lat = t
                    return {
                        'id': self.id,
                        'name': self.displayname,
                        'lon': g.lon * 1e-7,
                        'lat': g.lat * 1e-7,
                        'msl': g.msl * 1e-3,
                        'hacc': g.hacc * 1e-3,
                        'vacc': g.vacc * 1e-3,
                        'time': g.time
                    }
        return {}
Esempio n. 10
0
 def _from_json(geom_input):
     ptr = capi.from_json(geom_input)
     if GDAL_VERSION < (2, 0):
         try:
             capi.get_geom_srs(ptr)
         except SRSException:
             srs = SpatialReference(4326)
             capi.assign_srs(ptr, srs.ptr)
     return ptr
Esempio n. 11
0
 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
Esempio n. 12
0
 def set_srs(self, srs):
     "Sets the SpatialReference for this geometry."
     if isinstance(srs, SpatialReference):
         srs_ptr = clone_srs(srs._ptr)
     elif isinstance(srs, (int, long, basestring)):
         sr = SpatialReference(srs)
         srs_ptr = clone_srs(sr._ptr)
     else:
         raise TypeError(
             'Cannot assign spatial reference with object of type: %s' %
             type(srs))
     assign_srs(self._ptr, srs_ptr)
Esempio n. 13
0
    def transform(
        self, srs, driver=None, name=None, resampling="NearestNeighbour", max_error=0.0
    ):
        """
        Return a copy of this raster reprojected into the given spatial
        reference system.
        """
        # Convert the resampling algorithm name into an algorithm id
        algorithm = GDAL_RESAMPLE_ALGORITHMS[resampling]

        if isinstance(srs, SpatialReference):
            target_srs = srs
        elif isinstance(srs, (int, str)):
            target_srs = SpatialReference(srs)
        else:
            raise TypeError(
                "Transform only accepts SpatialReference, string, and integer "
                "objects."
            )

        if target_srs.srid == self.srid and (not driver or driver == self.driver.name):
            return self.clone(name)
        # 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": target_srs.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)
Esempio n. 14
0
 The OGRGeometry is a wrapper for using the OGR Geometry class
 (see https://www.gdal.org/classOGRGeometry.html).  OGRGeometry
 may be instantiated when reading geometries from OGR Data Sources
 (e.g. SHP files), or when given OGC WKT (a string).

 While the 'full' API is not present yet, the API is "pythonic" unlike
 the traditional and "next-generation" OGR Python bindings.  One major
 advantage OGR Geometries have over their GEOS counterparts is support
 for spatial reference systems and their transformation.

 Example:
  >>> from django.contrib.gis.gdal import OGRGeometry, OGRGeomType, SpatialReference
  >>> wkt1, wkt2 = 'POINT(-90 30)', 'POLYGON((0 0, 5 0, 5 5, 0 5)'
  >>> pnt = OGRGeometry(wkt1)
  >>> print(pnt)
  POINT (-90 30)
  >>> mpnt = OGRGeometry(OGRGeomType('MultiPoint'), SpatialReference('WGS84'))
  >>> mpnt.add(wkt1)
  >>> mpnt.add(wkt1)
  >>> print(mpnt)
  MULTIPOINT (-90 30,-90 30)
  >>> print(mpnt.srs.name)
  WGS 84
  >>> print(mpnt.srs.proj)
  +proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs
  >>> mpnt.transform(SpatialReference('NAD27'))
  >>> print(mpnt.proj)
  +proj=longlat +ellps=clrk66 +datum=NAD27 +no_defs
  >>> print(mpnt)
  MULTIPOINT (-89.999930378602485 29.999797886557641,-89.999930378602485 29.999797886557641)

  The OGRGeomType class is to make it easy to specify an OGR geometry type:
  >>> from django.contrib.gis.gdal import OGRGeomType
  >>> gt1 = OGRGeomType(3) # Using an integer for the type
  >>> gt2 = OGRGeomType('Polygon') # Using a string
  >>> gt3 = OGRGeomType('POLYGON') # It's case-insensitive
  >>> print(gt1 == 3, gt1 == 'Polygon') # Equivalence works w/non-OGRGeomType objects
  True True
Esempio n. 15
0
 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)
Esempio n. 16
0
 def srs(self, value):
     """
     Set the spatial reference used in this GDALRaster. The input can be
     a SpatialReference or any parameter accepted by the SpatialReference
     constructor.
     """
     if isinstance(value, SpatialReference):
         srs = value
     elif isinstance(value, (int, str)):
         srs = SpatialReference(value)
     else:
         raise ValueError("Could not create a SpatialReference from input.")
     capi.set_ds_projection_ref(self._ptr, srs.wkt.encode())
     self._flush()
Esempio n. 17
0
    def srs(self):
        """
<<<<<<< HEAD
        Returns the SpatialReference used in this GDALRaster.
=======
        Return the SpatialReference used in this GDALRaster.
>>>>>>> 37c99181c9a6b95433d60f8c8ef9af5731096435
        """
        try:
            wkt = capi.get_ds_projection_ref(self._ptr)
            if not wkt:
                return None
            return SpatialReference(wkt, srs_type='wkt')
        except SRSException:
            return None
Esempio n. 18
0
    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, (int, long, basestring)):
            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
Esempio n. 19
0
    def transform(self,
                  srid,
                  driver=None,
                  name=None,
                  resampling="NearestNeighbour",
                  max_error=0.0):
        """
        Return 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)
Esempio n. 20
0
    def transform(self, srs, driver=None, name=None, resampling='NearestNeighbour',
                  max_error=0.0):
        """
        Return a copy of this raster reprojected into the given spatial
        reference system.
        """
        # Convert the resampling algorithm name into an algorithm id
        algorithm = GDAL_RESAMPLE_ALGORITHMS[resampling]

        if isinstance(srs, SpatialReference):
            target_srs = srs
        elif isinstance(srs, (int, str)):
            target_srs = SpatialReference(srs)
        else:
            raise TypeError(
                'Transform only accepts SpatialReference, string, and integer '
                'objects.'
            )
        # 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': target_srs.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)
Esempio n. 21
0
    def transform(self, srid, driver=None, name=None, resampling='NearestNeighbour',
                  max_error=0.0):
        """
<<<<<<< HEAD
        Returns a copy of this raster reprojected into the given SRID.
=======
        Return a copy of this raster reprojected into the given SRID.
>>>>>>> 37c99181c9a6b95433d60f8c8ef9af5731096435
        """
        # 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)
Esempio n. 22
0
 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
     if isinstance(coord_trans, CoordTransform):
         geom_transform(self._ptr, coord_trans._ptr)
     elif isinstance(coord_trans, SpatialReference):
         geom_transform_to(self._ptr, coord_trans._ptr)
     elif isinstance(coord_trans, (int, long, basestring)):
         sr = SpatialReference(coord_trans)
         geom_transform_to(self._ptr, sr._ptr)
     else:
         raise TypeError(
             'Transform only accepts CoordTransform, SpatialReference, string, and integer objects.'
         )
Esempio n. 23
0
        "Returns the geometry type (OGRGeomType) of the Layer."
=======
        "Return the geometry type (OGRGeomType) of the Layer."
>>>>>>> 37c99181c9a6b95433d60f8c8ef9af5731096435
        return OGRGeomType(capi.get_fd_geom_type(self._ldefn))

    @property
    def srs(self):
<<<<<<< HEAD
        "Returns the Spatial Reference used in this Layer."
=======
        "Return the Spatial Reference used in this Layer."
>>>>>>> 37c99181c9a6b95433d60f8c8ef9af5731096435
        try:
            ptr = capi.get_layer_srs(self.ptr)
            return SpatialReference(srs_api.clone_srs(ptr))
        except SRSException:
            return None

    @property
    def fields(self):
        """
<<<<<<< HEAD
        Returns a list of string names corresponding to each of the Fields
=======
        Return a list of string names corresponding to each of the Fields
>>>>>>> 37c99181c9a6b95433d60f8c8ef9af5731096435
        available in this Layer.
        """
        return [force_text(capi.get_field_name(capi.get_field_defn(self._ldefn, i)),
                           self._ds.encoding, strings_only=True)
Esempio n. 24
0
        "Return the envelope as a 4-tuple, instead of as an Envelope object."
>>>>>>> 37c99181c9a6b95433d60f8c8ef9af5731096435
        return self.envelope.tuple

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

    # The SRS property
    def _get_srs(self):
<<<<<<< HEAD
        "Returns the Spatial Reference for this Geometry."
=======
        "Return the Spatial Reference for this Geometry."
>>>>>>> 37c99181c9a6b95433d60f8c8ef9af5731096435
        try:
            srs_ptr = capi.get_geom_srs(self.ptr)
            return SpatialReference(srs_api.clone_srs(srs_ptr))
        except SRSException:
            return None

    def _set_srs(self, srs):
<<<<<<< HEAD
        "Sets the SpatialReference for this geometry."
=======
        "Set the SpatialReference for this geometry."
>>>>>>> 37c99181c9a6b95433d60f8c8ef9af5731096435
        # 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
Esempio n. 25
0
def importData(file, characterEncoding, format, user, folder):
    cursor = connection.cursor()
    start_time = time.time()
    #manage zipfile
    fd, fname = tempfile.mkstemp(suffix=fileExt_dic[format])
    os.close(fd)
    f = open(fname, "wb")
    for chunk in file.chunks():
        f.write(chunk)
    f.close()

    if not zipfile.is_zipfile(fname):
        os.remove(fname)
        return "Not a valid zip archive.", None
    zip = zipfile.ZipFile(fname)

    hasSuffix = {}
    required_suffixes = suffixes_dic[format]
    for suffix in required_suffixes:
        hasSuffix[suffix] = False
    for info in zip.infolist():
        extension = os.path.splitext(info.filename)[1].lower()
        if extension in required_suffixes:
            hasSuffix[extension] = True
    for suffix in required_suffixes:
        if not hasSuffix[suffix]:
            zip.close()
            os.remove(fname)
            return "Archive missing required %s file." % suffix, None

    zip = zipfile.ZipFile(fname)
    shapefileName = None
    dirname = tempfile.mkdtemp()
    for info in zip.infolist():
        if info.filename.lower().endswith(filenameExt_dic[format]):
            shapefileName = info.filename
        dstFile = os.path.join(dirname, info.filename)
        f = open(dstFile, "wb")
        f.write(zip.read(info.filename))
        f.close()
    zip.close()

    #verify if shapefile is valid
    try:
        srcPath = os.path.join(dirname, shapefileName)
        srcLayers = fiona.listlayers(srcPath)
        shapefileOK = True
    except:
        traceback.print_exc()
        shapefileOK = False
    if not shapefileOK:
        os.remove(fname)
        shutil.rmtree(dirname)
        return "Not a valid vector file.", None

    #add shapefile object to database
    try:
        for i in srcLayers:
            with fiona.open(srcPath) as c:
                srcSpatialRef = to_string(c.crs)
                print srcSpatialRef
                project = CoordTransform(SpatialReference(srcSpatialRef),
                                         SpatialReference(3857))
                geometryType = c.schema['geometry']
                shapefile = Shapefile.objects.create(
                    filename=c.name,
                    parent=folder,
                    srs_wkt=srcSpatialRef,
                    geom_type=geometryType,
                    encoding=characterEncoding,
                    created_by=user)

                #define shapefile's attributes
                for keys, values in c.schema['properties'].iteritems():
                    dict = {}
                    dict['name'] = keys
                    props = re.split('\W+', values)
                    dict['type'] = utils.fionaTypeToInt(props[0])
                    try:
                        dict['width'] = int(props[1])
                    except IndexError:
                        dict['width'] = 0
                    if dict['type'] == 2:
                        try:
                            dict['precision'] = int(props[2])
                        except IndexError:
                            dict['precision'] = 15
                    else:
                        dict['precision'] = 0
                    attr = Attribute.objects.create(shapefile=shapefile,
                                                    **dict)

                #store shapefile's features
                for srcFeature in c:
                    try:
                        wkt = dumps(srcFeature['geometry'])
                        geosGeometry = GEOSGeometry(wkt)
                        geosGeometry.srid = SpatialReference(
                            srcSpatialRef).srid
                        geosGeometry.transform(project)
                    except TypeError:
                        geosGeometry = None

                    geometryField = utils.calcGeometryField(geometryType)

                    args = {}
                    args['shapefile'] = shapefile
                    args[geometryField] = geosGeometry
                    args['attribute_value'] = srcFeature['properties']
                    args['id_relat'] = srcFeature['id']
                    feature = Feature.objects.create(**args)

            print("Temps final: --- %s seconds ---" %
                  str(time.time() - start_time))
            return None, shapefile

    except BaseException, e:
        #cleaning up
        os.remove(fname)
        shutil.rmtree(dirname,
                      ignore_errors=False,
                      onerror=handleRemoveReadonly)
        shapefile.delete()
        return e, None
Esempio n. 26
0
PROJCS["NAD_1983_StatePlane_Pennsylvania_South_FIPS_3702_Feet",
    GEOGCS["GCS_North_American_1983",
        DATUM["North_American_Datum_1983",
            SPHEROID["GRS_1980",6378137,298.257222101]],
        PRIMEM["Greenwich",0],
        UNIT["Degree",0.017453292519943295]],
    PROJECTION["Lambert_Conformal_Conic_2SP"],
    PARAMETER["False_Easting",1968500],
    PARAMETER["False_Northing",0],
    PARAMETER["Central_Meridian",-77.75],
    PARAMETER["Standard_Parallel_1",39.93333333333333],
    PARAMETER["Standard_Parallel_2",40.96666666666667],
    PARAMETER["Latitude_Of_Origin",39.33333333333334],
    UNIT["Foot_US",0.30480060960121924],
    AUTHORITY["EPSG","102729"]]"""
srs = SpatialReference(SRS_WKT)


class CrimeScraper(NewsItemListDetailScraper):
    schema_slugs = ('crime', )
    has_detail = False

    def __init__(self, start_date=None, end_date=None):
        super(CrimeScraper, self).__init__()
        self.start_date, self.end_date = start_date, end_date

    def list_pages(self):
        # Yields CSV documents
        for crime_type in (10, 11, 12, 13, 20, 30, 31, 32, 40, 41, 42, 50, 51,
                           52, 53, 54, 60, 61, 62, 63, 64, 65, 66, 67, 70, 71,
                           72):
Esempio n. 27
0
<<<<<<< HEAD
        Sets the spatial reference used in this GDALRaster. The input can be
=======
        Set the spatial reference used in this GDALRaster. The input can be
>>>>>>> 37c99181c9a6b95433d60f8c8ef9af5731096435
        a SpatialReference or any parameter accepted by the SpatialReference
        constructor.
        """
        if isinstance(value, SpatialReference):
            srs = value
<<<<<<< HEAD
        elif isinstance(value, six.integer_types + six.string_types):
=======
        elif isinstance(value, (int, str)):
>>>>>>> 37c99181c9a6b95433d60f8c8ef9af5731096435
            srs = SpatialReference(value)
        else:
            raise ValueError('Could not create a SpatialReference from input.')
        capi.set_ds_projection_ref(self._ptr, srs.wkt.encode())
        self._flush()

    @property
    def srid(self):
        """
        Shortcut to access the srid of this GDALRaster.
        """
        return self.srs.srid

    @srid.setter
    def srid(self, value):
        """