2016-02-19 71 views
0

嘗試解析在Django殼.SHP:GeoDjango內置GDAL_ERROR時

from django.contrib.gis.gdal import DataSource 
ds = DataSource('/Users/.../Downloads/Iceland.shp') 

得到:

GDAL_ERROR 4: Unable to open /Users/.../Downloads/Iceland.shx or /Users/.../Downloads/Iceland.SHX. 

Traceback (most recent call last): 
    File "<console>", line 1, in <module> 
    File "/Users/.../lib/python2.7/site-packages/django/contrib/gis/gdal/datasource.py", line 78, in __init__ 
    raise GDALException('Could not open the datasource at "%s"' % ds_input) 
GDALException: Could not open the datasource at "/Users/.../Downloads/Iceland.shp" 

文件存在,文件模式爲755,.SHX文件是正確的(在測試在線服務)。 後來我嘗試測試.KML文件,它的工作原理

操作系統:Mac OS X 10.10.5

+1

我會嘗試一些事情:1。檢查的強制.SHX,.SHP和.dbf文件在同一目錄下。 2.檢查沒有其他程序使shapefile打開(並鎖定)。 3.在QGIS/ArcGIS中打開shapefile並驗證幾何體。 4.嘗試另一個shapefile。 – Alexander

回答

1

你缺少 「Iceland.shx」 文件。它應該與Iceland.shp位於同一個檔案中。把它放在同一個目錄下。我試過這個文件:http://www.eea.europa.eu/data-and-maps/data/eea-reference-grids-2/gis-files/iceland-shapefile並且發現相同的錯誤。

如果它不會幫助,還有一些其他的選擇如何調試:

  1. 檢查強制性.SHX,.SHP和.dbf文件在同一目錄下。
  2. 檢查沒有其他程序將shapefile打開(並鎖定)。
  3. 打開QGIS/ArcGIS中的shapefile文件並驗證幾何體。
  4. 嘗試另一個shape文件
相關問題