summaryrefslogtreecommitdiff
path: root/chimere/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'chimere/utils.py')
-rw-r--r--chimere/utils.py17
1 files changed, 10 insertions, 7 deletions
diff --git a/chimere/utils.py b/chimere/utils.py
index 09255d0..c7502db 100644
--- a/chimere/utils.py
+++ b/chimere/utils.py
@@ -31,7 +31,6 @@ import unicodedata
import zipfile
from lxml import etree
-from osgeo import osr
from django.conf import settings
from django.contrib.gis.gdal import DataSource, Driver, OGRGeometry, \
@@ -237,12 +236,16 @@ class ShapefileManager(ImportManager):
srid = self.importer_instance.srid
if not srid:
prjfilename = tmpdir + os.sep + sources[2]
- with open(prjfilename, 'r') as prj_file:
- prj_txt = prj_file.read()
- srs = osr.SpatialReference()
- srs.ImportFromESRI([prj_txt])
- srs.AutoIdentifyEPSG()
- srid = srs.GetAuthorityCode(None)
+ try:
+ from osgeo import osr
+ with open(prjfilename, 'r') as prj_file:
+ prj_txt = prj_file.read()
+ srs = osr.SpatialReference()
+ srs.ImportFromESRI([prj_txt])
+ srs.AutoIdentifyEPSG()
+ srid = srs.GetAuthorityCode(None)
+ except ImportError:
+ pass
if not srid:
# try with the default projection
srid = settings.CHIMERE_EPSG_DISPLAY_PROJECTION