readme cleanup

This commit is contained in:
Sam
2021-01-21 13:48:46 +00:00
parent 984bea0038
commit 7c31052436

View File

@@ -26,28 +26,4 @@ python migrate
To load initial location data use: `python manage.py addgeo`
```python
from geo.models import Region
from django.contrib.gis.geos import GEOSGeometry, MultiPolygon
import json
path='gadm36_ESP_1.json'
feature_collection = json.loads(open(path).read())
for feature in feature_collection['features']:
geom = GEOSGeometry(str(feature['geometry']))
if feature['geometry']['type'] == "MultiPolygon":
poly_list = []
for poly in geom:
poly_list.append(poly)
print(poly_list)
else:
poly_list = geom
geom_geos = MultiPolygon(poly_list)
name = feature['properties']['NAME_1']
region = Region.objects.create(name=name,geo=geom_geos)
region.save()
```