diff --git a/core/management/commands/addgeo.py b/core/management/commands/addgeo.py index 33dac52..89c3117 100644 --- a/core/management/commands/addgeo.py +++ b/core/management/commands/addgeo.py @@ -3,6 +3,7 @@ import json from django.core.management.base import BaseCommand from django.contrib.gis.geos import GEOSGeometry, MultiPolygon +from django.contrib.gis.gdal import DataSource from geo.models import City, Region, Province, Country @@ -15,7 +16,7 @@ logging.basicConfig( class Command(BaseCommand): - 'help' = 'Load geographic dataset' + help = 'Load geographic dataset' def handle(self, *args, **kwargs): print('Deleting all instances of Country, Region, Province, City') @@ -25,6 +26,9 @@ class Command(BaseCommand): Region.objects.all().delete() Country.objects.all().delete() + # load GADM data data source + ds = DataSource('datasets/gadm36_ESP.gpkg') + # create country for spain country = Country.objects.create(name='EspaƱa') diff --git a/datasets/gadm36_ESP.gpkg b/datasets/gadm36_ESP.gpkg new file mode 100644 index 0000000..5c9c801 Binary files /dev/null and b/datasets/gadm36_ESP.gpkg differ