In [1]:
import logging
root = logging.getLogger()
root.addHandler(logging.StreamHandler())
import matplotlib.pyplot as plt
%matplotlib inline
In [2]:
from iSDM.species import IUCNSpecies
turtles = IUCNSpecies(name_species='Pelusios rhodesianus')
turtles.load_shapefile('../data/FW_TURTLES/FW_TURTLES.shp')
In [3]:
turtles.find_species_occurrences()
Out[3]:
In [4]:
type(turtles)
Out[4]:
In [5]:
turtles.plot_species_occurrence()
In [6]:
turtles.save_shapefile("../data/filtered_turtles_again.shp")
In [7]:
from iSDM.environment import ClimateLayer
worldclim_max_june = ClimateLayer(file_path="../data/tmax1/tmax6.bil")
worldclim_max_june.load_data()
Out[7]:
In [8]:
worldclim_data = worldclim_max_june.read(1) # read band_1
# get the min (ignoring nodata=-9999)/max values to adjust the spectrum.
vmin = worldclim_data[worldclim_data!=worldclim_max_june.metadata["nodata"]].min()
vmax = worldclim_data.max()
In [9]:
fig, ax = plt.subplots(figsize=(18, 18))
ax.imshow(worldclim_max_june.read(1), cmap="coolwarm", interpolation="none", vmin=vmin, vmax=vmax)
Out[9]:
In [10]:
worldclim_max_june.overlay(turtles)
# if i don't limit the plot to vmin/vmax, the image is almost white, because low values are really low.
# So we need scaling of the colormap
vmin = worldclim_max_june.masked_data.data[worldclim_max_june.masked_data.data!=worldclim_max_june.metadata['nodata']].min()
vmax=worldclim_max_june.masked_data.data.max()
In [11]:
fig, ax = plt.subplots(figsize=(18, 18))
ax.imshow(worldclim_max_june.masked_data, cmap="coolwarm", interpolation="none", vmin=vmin, vmax=vmax) # vmin/vmax for better contrast?
Out[11]:
In [12]:
worldclim_max_june.masked_data # there are .data and .mask arrays
Out[12]:
In [13]:
worldclim_max_june.masked_data.mask
Out[13]:
In [14]:
worldclim_max_june.masked_data.data
Out[14]:
In [15]:
# convert to lower resolution?
worldclim_max_june.reproject(destination_file="../data/reprojected.adf", resolution=1, driver='AIG')
In [16]:
# load the lower resolution file? or should reprojecting "overwrite" the original data
worldclim_max_june.load_data("../data/reprojected.adf")
Out[16]:
In [17]:
fig, ax = plt.subplots(figsize=(18, 18))
vmin = worldclim_max_june.masked_data.data[worldclim_max_june.masked_data.data!=worldclim_max_june.metadata['nodata']].min()
vmax=worldclim_max_june.masked_data.data.max()
ax.imshow(worldclim_max_june.read(1), cmap="coolwarm", interpolation="none", vmin=vmin, vmax=vmax)
Out[17]:
In [18]:
worldclim_max_june.overlay(turtles)
# if i don't limit the plot to vmin/vmax, the image is almost white, because low values are really low.
# So we need scaling of the colormap
vmin = worldclim_max_june.masked_data.data[worldclim_max_june.masked_data.data!=worldclim_max_june.metadata['nodata']].min()
vmax = worldclim_max_june.masked_data.data.max()
In [19]:
fig, ax = plt.subplots(figsize=(18, 18))
ax.imshow(worldclim_max_june.masked_data, cmap="coolwarm", interpolation="none", vmin=vmin, vmax=vmax) # vmin/vmax for better contrast?
Out[19]:
Overlaying DEM data with shapefiles is analogous
In [ ]: