readme cleanup
This commit is contained in:
24
README.md
24
README.md
@@ -26,28 +26,4 @@ python migrate
|
|||||||
|
|
||||||
To load initial location data use: `python manage.py addgeo`
|
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()
|
|
||||||
|
|
||||||
```
|
|
||||||
|
|||||||
Reference in New Issue
Block a user