Save the data in a polygonfield

0

Good evening,

I'm implementing a project using django and I have the following model:

class ModelExample(models.Model):
    city = models.CharField("Cidade", max_length=100, blank=True)
    state = models.CharField("Estado", max_length=2, blank=True)
    polygon = gis_models.PolygonField(default='POLYGON EMPTY')

And I have the json of the link below: link

The idea is to always search via pointfields of another model if a particular neighborhood is contained within the city. It would be something like ModelExample.objects.get (polygon__contains = OtherModel.point)

My big question is how do I save the json (geometry) [bounds] data in polygonfield?

    
asked by anonymous 30.11.2017 / 22:59

1 answer

0

I was able to solve my problem using the link app. With it I have models ready to manipulate data of cities and states of Brazil and it has a ready shp file with ibge data as the geographic coordinates of each city of Brazil. Once this file was imported (using the python command manage.py loaddata filenamehp), it was enough to use GeoDjango's ready-made functions that searches for existing streets or not in a city worked correctly.

    
19.02.2018 / 00:00