You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As you know, the point sampling of rasterstats, which pyimute relies on, is quite slow. I've been using QGIS' Point sampling tool plugin as an alternative to this. This is definitely fast in speed, but I wanted to do everything in a Python environment without running QGIS if possible.
from pathlib import Path
for file in raster_features:
src = rasterio.open(file)
gdf[Path(file).stem] = [x for x in src.sample(coord_list)]
gdf[Path(file).stem] = gdf[Path(file).stem].astype('float64')
The text was updated successfully, but these errors were encountered:
Thanks again for developing PySDMs. I want to share a little idea about PySDMs and Python-SDM you wrote earlier (https://github.com/daniel-furman/Python-species-distribution-modeling/blob/main/Python-sdm.ipynb) .
As you know, the point sampling of rasterstats, which pyimute relies on, is quite slow. I've been using QGIS' Point sampling tool plugin as an alternative to this. This is definitely fast in speed, but I wanted to do everything in a Python environment without running QGIS if possible.
In this regard, there is a point sampling function called rasterio.sample module(https://rasterio.readthedocs.io/en/latest/api/rasterio.sample.html) in the rasterio package that is also used by PySDMs. I tested it and the speed is also very fast! I finished a small test today and uploaded the source code to my github. I would like to share the link. Hope this helps in future updates.
https://github.com/osgeokr/SDM/blob/main/SDM_Species_Distribution_Modeling_v.0.4.ipynb
gdf = gpd.GeoDataFrame.from_file("DATA/JTREE.shp")
coord_list = [(x,y) for x,y in zip(gdf['geometry'].x , gdf['geometry'].y)]
raster_features = sorted(glob.glob('DATA/BIOCLIM/bclim*.asc'))
from pathlib import Path
for file in raster_features:
src = rasterio.open(file)
gdf[Path(file).stem] = [x for x in src.sample(coord_list)]
gdf[Path(file).stem] = gdf[Path(file).stem].astype('float64')
The text was updated successfully, but these errors were encountered: