I have implemented GeoDjango using postgis.
Here is my model:
...
geometria = models.PolygonField(srid=4326, null=True)
...
When I call data.area it returns a float, but I don’t have any clues about it’s measurement units, and it’s a problem because I want to test if it’s bigger of a pre-set area in squared meters.
Can you help me?
If you are dealing with large areas on the map, you should set
As mentioned in geodjango’s documentation https://docs.djangoproject.com/en/dev/ref/contrib/gis/model-api/#geography
If you do not have
geography=True, we are storing things as plain geometries, we will need to do conversion fromsquare degrees(the floating point result you are getting) into a unit of measure you prefer because we cannot calculate area from geographic coordinates. We can instead add a helper method which is in a projected coordinate space to do the transformation:Which projection we use depends on the extent of the data, and how accurate we need the results: here I’ve illustrated with a specific projection for part of New York, but if your data isn’t particularly accurate, you could easily substitute a global projection or just use a simple formula.