Esempio n. 1
0
def test_geofeature_from_record_with_empty_rasters(request):
    record = {
        'geometry': mapping(Point(0.0, 1.1)),
        'properties': {},
        'raster': []
    }
    feature = GeoFeature.from_record(record, WGS84_CRS)
    assert isinstance(feature, GeoFeature)
Esempio n. 2
0
def test_geofeature_from_record_for_a_record_with_raster(raster, request):
    raster = request.getfixturevalue(raster)
    properties = OrderedDict([('prop1', 1), ('prop2', '2'),
                              ('prop3', datetime(2018, 4, 25, 11, 18))])
    feature = GeoFeature.from_raster(raster, properties=properties)
    feature2 = GeoFeature.from_record(feature.to_record(feature.crs),
                                      feature.crs)
    assert feature.raster() == feature2.raster()
    assert feature.geometry == feature2.geometry
    assert feature2.to_record(feature2.crs)['properties'] == feature.to_record(
        feature.crs)['properties']
    assert feature2.crs == feature2.raster().crs
Esempio n. 3
0
 def __iter__(self):
     with fiona.open(self._filename, 'r') as source:
         for record in source:
             yield GeoFeature.from_record(record, self.crs, source.schema)
Esempio n. 4
0
 def from_record(cls, record, crs):
     features = record.get("features", [])
     features = [GeoFeature.from_record(f, crs) for f in features]
     return cls(features)
Esempio n. 5
0
 def __iter__(self):
     if hasattr(self._fp, 'seek'):
         self._fp.seek(0)
     with fiona.open(self._fp, 'r') as source:
         for record in source:
             yield GeoFeature.from_record(record, self.crs, source.schema)