19

I am not able to read the shape file. It says no such working directory. enter image description here

!pip install sentinelsat
!pip install geopandas
!pip install folium
from sentinelsat import SentinelAPI
user = '****' 
password = '****' 
api = SentinelAPI(user, password, 'https://scihub.copernicus.eu/dhus')
import geopandas as gpd
import folium 

nReserve = gpd.read_file(r"G:\New folder (2)\cardinialres.shp")

m = folium.Map([-37.971389,  145.418889], zoom_start=12)
folium.GeoJson(nReserve).add_to(m)
m

''I googled and found that I need to use SHAPE_RESTORE_SHX=YES fio info myshapefile.shp but do not know where to use in Jupiter lab.

3 Answers3

31

All the file which come with .shp file should be in same folder (.shx, .prj, .dbf)

Akash Desai
  • 447
  • 5
  • 10
  • True, but the issue can arise when the .shx file is corrupted, not when it is missing. Nothing to do with not having all the shapefile files in a folder. – user27874 Mar 30 '23 at 09:13
3

Fix this issue, after a little more understanding of the .shp objects. The solution is to have all other relevant files that come along with .shp file in one folder!

if you working with the river dataset Ex. river.shp river.prj river.dbf river.shx

MD Gazuruddin
  • 540
  • 5
  • 9
2

set GDAL config like this and it will create missing SHX

from osgeo import gdal
import geopandas as gpd
gdal.SetConfigOption('SHAPE_RESTORE_SHX', 'YES')
in_vector = '/Users/adi/projects/cds_scrap/f6089a8c/f6089a8c.shp'
gdf = gpd.read_file(in_vector)