yotarazona / scikit-eo

A Python package for Remote Sensing Data Analysis
https://yotarazona.github.io/scikit-eo/
Other
15 stars 2 forks source link

Bug in notebook 11: type error (shapefile) #12

Closed dbuscombe-usgs closed 3 weeks ago

dbuscombe-usgs commented 1 month ago

ping https://github.com/openjournals/joss-reviews/issues/6692

Cell 7 in notebook 11

endm = extract(img, endm)

returns the following error

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[7], line 2
      1 # endmembers
----> 2 endm = extract(img, endm)
      3 endm

File ~/scikit-eo/scikeo/process.py:136, in extract(image, shp)
    133     raise TypeError('"image" must be raster read by rasterio.open().')
    135 if not isinstance(shp, (gpd.geodataframe.GeoDataFrame)):
--> 136     raise TypeError('"shp" must be Shapefile (.shp)')
    138 gdf = gpd.GeoDataFrame(geometry = shp['geometry'])
    140 coords = [(x,y) for x, y in zip(gdf['geometry'].x, gdf['geometry'].y)]

TypeError: "shp" must be Shapefile (.shp)

The variables above have been defined like so, using the files downloaded from your google drive links

path_raster = r'/home/marda/Downloads/11_deepLearning/LC08_232066_20190727_SR.tif'
img = rasterio.open(path_raster)

path_endm = r"/home/marda/Downloads/11_deepLearning/endmembers.dbf"
endm = DBF(path_endm)
yotarazona commented 1 month ago

Hi @dbuscombe-usgs, thanks!. The shapefile used was updated, now

path_raster = r"C:\Users\USER\Desktop\Github_Repo\scikiteo_data\11_deepLearning\LC08_232066_20190727_SR.tif"
img = rasterio.open(path_raster)

path_endm = r"C:\Users\USER\Desktop\Github_Repo\scikiteo_data\11_deepLearning\endmembers.shp"
endm = gpd.read_file(path_endm)

Machine learning and deep learning in scikit-eo can be run using both a dbf and .shp which contain the samples to be used.