In [1]:
import logging
root = logging.getLogger()
root.addHandler(logging.StreamHandler())
%matplotlib inline
In [2]:
# download http://bit.ly/1R8pt20 (zipped Turtles shapefiles), and unzip them
from iSDM.species import IUCNSpecies
turtles = IUCNSpecies(name_species='Acanthochelys pallidipectoris')
turtles.load_shapefile('../data/FW_TURTLES/FW_TURTLES.shp')
In [3]:
turtles.get_data().head()
Out[3]:
In [4]:
turtles.get_data().columns # all the columns available per species geometry
Out[4]:
In [5]:
turtles.find_species_occurrences()
In [6]:
turtles.get_data() # datatype: geopandas.geodataframe.GeoDataFrame
Out[6]:
In [7]:
turtles.save_data() # serialize all the current data to a pickle file, so it can be loaded later on
In [8]:
turtles.load_data()
Out[8]:
In [9]:
turtles.ID # derived from "id_no" column. It's a sort of unique ID per species
Out[9]:
In [10]:
turtles.get_data().plot()
turtles.data_full.geometry.convex_hull.plot()
Out[10]:
In [11]:
with_buffer = turtles.get_data().geometry.buffer(0.5)
with_buffer.plot()
Out[11]:
In [12]:
turtles.save_shapefile(overwrite=True)
In [13]:
turtles.rasterize_data(raster_file='./turtles.tif', pixel_size=0.5)
In [14]:
turtles_raster_data = turtles.load_raster_data()
In [15]:
turtles_raster_data.shape
Out[15]:
In [16]:
type(turtles_raster_data)
Out[16]:
In [17]:
import matplotlib.pyplot as plt
plt.figure(figsize=turtles_raster_data.shape) # careful with big images!
plt.imshow(turtles_raster_data, cmap="hot", interpolation="none")
Out[17]:
In [19]:
type(turtles_raster_data)
Out[19]:
In [21]:
from osgeo import gdal, ogr
geo = gdal.Open("./turtles.tif")
In [23]:
geo.GetGCPs()
Out[23]:
In [24]:
drv = geo.GetDriver()
In [28]:
geo.RasterXSize
Out[28]:
In [29]:
geo.GetGeoTransform()
Out[29]:
In [ ]: