Ejemplo n.º 1
0
 def get_raster_prep_value(self, value, is_candidate):
     """
     Return a GDALRaster if conversion is successful, otherwise return None.
     """
     if isinstance(value, gdal.GDALRaster):
         return value
     elif is_candidate:
         with suppress(GDALException):
             return gdal.GDALRaster(value)
     elif isinstance(value, dict):
         try:
             return gdal.GDALRaster(value)
         except GDALException:
             raise ValueError("Couldn't create spatial object from lookup value '%s'." % value)
Ejemplo n.º 2
0
 def gdal_raster(faker, field, srid, *args, **kwargs):
     scale = faker.pyfloat(positive=True)
     return gdal.GDALRaster({
         "width":
         faker.random_int(min=1, max=1024),
         "height":
         faker.random_int(min=1, max=1024),
         "name":
         faker.word(),
         "srid":
         srid,
         "scale": [scale, -scale],
         "bands": [{
             "data": range(faker.random_int(min=1, max=1024))
         }],
     })