Adds an ID column if it doesn't already exists. If column named after name_column parameter does not exist in the geodataframe, adds one with integers from 1 to the number of observations.
Parameters
----------
obs : geopandas GeoDataFrame
Observation points or polygons
name_column : str
Name of the ID column.
Returns
-------
obs : geopandas GeoDataFrame
Observation points or polygons with added column named using parameter name_column if it doesn't already exist.
buffer_obs
defbuffer_obs(obs,buffer,name_column)
Applies a buffer to dilate or erode observations. Names of discarded observations too small compared to a eroding buffer are printed.
Parameters
----------
obs : geopandas GeoDataFrame
Observation points or polygons with a column named name_column used to identify observations.
buffer : int
Length in meters of the buffer used to dilate (positive integer) or erode (negative integer) the observations. Some observations may disappear completely if a negative buffer is applied.
name_column : str
Name of the column used to identify observations.
Returns
-------
obs : geopandas GeoDataFrame
Observation polygons with the buffer applied.
Get bounds of around of a polygons so it matches the limits of Sentinel-2 pixels
Parameters
----------
obs : geopandas GeoDataFrame
A polygon
Returns
-------
bounds : 1D array
Bounds around the polygon
Generates points in a grid corresponding to the centroids of Sentinel-2 pixels inside the polygons.
Parameters
----------
obs_polygons : geopandas GeoDataFrame
Observation polygons with a column named name_column used to identify observations.
sentinel_dir : str
Path of directory containing Sentinel-2 data.
name_column : str
Name of the column used to identify observations.
list_tiles : list
A list of names of Sentinel-2 directories. If this parameter is used, extraction is limited to those directories.
Returns
-------
grid_points : geopandas GeoDataFrame
Points corresponding to the centroids of the Sentinel-2 pixels of each Sentinel-2 tile intersecting with the polygons.
Creates a Sentinel-2 tiles extent vector from existing Sentinel-2 data
Parameters
----------
sentinel_dir : str
Path of directory containing Sentinel-2 data.
list_tiles : list
A list of names of Sentinel-2 directories. If this parameter is used, extraction is limited to those directories.
Returns
-------
concat_areas : geopandas GeoDataFrame
Vector containing the extent of Sentinel-2 tiles contained in sentinel_dir directory, with 'epsg' and 'area_name' columns corresponding to the projection system and the name of the tile derived from the name of the directory containing its data.
Observations polygons are intesected with Sentinel-2 tiles extent vector. Intersections where the observation polygon did not entirely fit in the sentinel-2 tile are removed.
Observation polygons which intersect no Sentinel-2 tiles are removed and their IDs are printed.
Parameters
----------
obs_polygons : geopandas GeoDataFrame
Polygons of observations.
sen_polygons : geopandas GeoDataFrame
Polygons of Sentinel-2 tiles extent with 'area_name' and 'epsg' columns corresponding to the name of the tile, and the projection system respectively.
name_column : str
Name of the ID column.
Returns
-------
geopandas GeoDataFrame
Intersection of obs_polygons and sen_polygons, with incomplete intersections removed.
polygons_to_grid_points
defpolygons_to_grid_points(polygons,name_column)
Converts polygons to points corresponding to the centroids of the Sentinel-2 pixels of each Sentinel-2 tile intersecting with the polygons.
Prints polygons with no pixels centroids inside of them.
Parameters
----------
polygons : geopandas GeoDataFrame
Observation polygons with 'area_name' and 'epsg' columns, corresponding to the name of a Sentinel-2 tile and its CRS respectively.
name_column : str
Name of the ID column.
Returns
-------
grid_points : geopandas GeoDataFrame
Points corresponding to the centroids of the Sentinel-2 pixels of each Sentinel-2 tile intersecting with the polygons.