How to convert Polygon object in Django GIS to an image

I am running a Django project, I created a Company model with company_activity_area field.

My goal is to generate an image from the map. and even better, to generate a map image for each polygon.

this is my code.


from django.contrib.gis.db import models

class Company(models.Model):
    company_activity_area = models.MultiPolygonField(null=True, blank=True, 
                                                        srid=4326,
                                                        verbose_name='Area of Operation')
    def save(self, *args, **kwargs):
        for polygon in self.company_activity_area:
            # TODO: generate the map image for each polygon, where the polygon appear at the middle of the map
            
        super(Company, self).save(*args, **kwargs)
Back to Top