philippWassibauer / django-natural-earth

an importer for Natural Earth (http://www.naturalearthdata.com) Data into GeoDjano
8 stars 1 forks source link

Failure on ne_import_countries using the updated dataset #1

Open dhilton opened 14 years ago

dhilton commented 14 years ago

Tried to initialise the countries database using the managment commands. Got the following error: Datasource has 1 layers Importing Layer 10m_admin_1_version1b1 of type Polygon, size: 3786 Traceback (most recent call last): File "./manage.py", line 16, in execute_manager(settings) File "/var/www/python/mapy/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/core/management/init.py", line 362, in execute_manager utility.execute() File "/var/www/python/mapy/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/core/management/init.py", line 303, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/var/www/python/mapy/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/core/management/base.py", line 195, in run_from_argv self.execute(_args, _options.dict) File "/var/www/python/mapy/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/core/management/base.py", line 222, in execute output = self.handle(_args, _options) File "/var/www/python/mapy/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/core/management/base.py", line 322, in handle label_output = self.handle_label(label, options) File "./django-natural-earth/natural_earth/management/commands/ne_import_countries.py", line 35, in handle_label transform=False, encoding='iso-8859-1') File "/var/www/python/mapy/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/contrib/gis/utils/layermapping.py", line 187, in init** self.check_layer() File "/var/www/python/mapy/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/contrib/gis/utils/layermapping.py", line 319, in check_layer idx = check_ogr_fld(ogr_name) File "/var/www/python/mapy/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/contrib/gis/utils/layermapping.py", line 265, in check_ogr_fld raise LayerMapError('Given mapping OGR field "%s" not found in OGR Layer.' % ogr_map_fld) django.contrib.gis.utils.layermapping.LayerMapError: Given mapping OGR field "SHAPE_AREA" not found in OGR Layer.

I think it's something to do with the mapping as I altered the mapping dict to:

country_mapping = { 'name' : 'NAME_0', 'shape_leng' : 'Shape_Leng', 'shape_area' : 'Shape_Area', 'mpoly' : 'MULTIPOLYGON', }

And it imported the data - incorrectly - but it imported it and it was viewable in the admin.

I guess this may be a dirty data issue?

philippWassibauer commented 14 years ago

hello, the original is: country_mapping = { 'name' : 'COUNTRY', 'featurecla' : 'FEATURECLA', 'sov' : 'SOV', 'shape_leng' : 'SHAPE_LENG', 'shape_area' : 'SHAPE_AREA', 'mpoly' : 'MULTIPOLYGON', } maybe try it with SHAPE_AREA again. Otherwise the data structure might have changed and the mapping file has to be adapted. This is actually the reason why i posted this, since i figured that many people want this data and it is a headache to keep the importer working as schemas change. I will take a look at it later...but if you feel like it you can read through: http://geodjango.org/docs/tutorial.html#geographic-data and use ogrinfo to find out how the new schema looks like.

dhilton commented 14 years ago

I had a play and managed to get it to import if I changed some of the mappings. Will have a further play today and fork your repositry and see if I can't help out. Cheers,Dan