I try to make some raster statistics based on Django and rasterstats lib. User requests GeoJson and in the response, I should also provide GeoJson. Geometry should be stored in the database model.
For now, I have things working using
models.PolygonField, but I would like to add to that other geometry types.
I am using django-rest-framework-gis
class CalculateLocation(Base): id = models.AutoField(primary_key=True) otherProperties = models.CharField(max_length=2000) geometry = models.PolygonField(blank=True) min = models.CharField(blank=True, max_length=20) max = models.CharField(blank=True, max_length=20) mean = models.CharField(blank=True, max_length=20)
class CalculateLocationSerializer(GeoFeatureModelSerializer): class Meta: model = CalculateLocation geo_field = "geometry" fields = ( 'id', 'otherProperties', 'min', 'max', 'mean' )
How can I store and serialize/deserialize vary geometry type in one field, for example, Point, Polygon, Multipolygon etc.?