The r.pi GRASS extension is now published and available through the GRASS extension repository. It provides a range of functionality and allows to easily analyze spatial patch attributes in GRASS. Patches are expected to be raster objects derived from remote sensing data and their spatial characteristics is written into a new spatial file for further analysis.
The list of functions outlined in our recent publication in MEE can be seen here. More functions are available in the r.pi package but not specifically mentioned.
After the semester holidays, we welcome our EAGLE students back to their second semester!
Some of them already took the chance to take part in a short course on landscape ecology for wetland monitoring and management with QGIS given by the ERASMUS lecturer Dr. Aurelie Davranche (more) the last two days.
Today, the course “Advanced spatial analysis for geoscientists – object-oriented image analysis” started. It is a hands-on-data-seminar jointly given by our colleagues Dr. Michael Thiel, who will teach eCognition during the summer term, and Dr. Christian Geiss who will be at our department until the end of the week. Christian is an invited guest lecturer from DLR’s Remote Sensing Data Center (Department: Geo-Risks and Civil Security) and he is working on mapping and characterization of urban areas with respect to risk and vulnerability assessment. If you want to learn more about Christian’s Team click here.
We wish all students and lecturers interesting seminars (full list) and a successfull summer term!
Our colleagues at DLR released a platform which allows easy and free of charge access to Sentinel remote sensing data:
CODE-DE makes possible free-of-charge, simple access to data from the Sentinel satellites and to information products from the European Copernicus programme–including an up-to-date cloud-free mosaic of Germany, produced at EOC. The platform will also provide access to national geodata infrastructure (GDI-DE). This portal provides harmonised and standardised German geodata from a wide variety of sources. By agreement with industrial partners it is also planned to offer data from the German radar satellites TerraSAR-X and TanDEM-X as well as high-resolution optical images from RapidEye satellites.
CODE-DE offers a one-stop shop. The data is collected in a single portal so that users no longer have to search through various databases, as formerly. This gives them direct access to an enormous amount of data—the Sentinel satellites alone will produce a data volume of some 50 petabytes by the end of 2020.
read more: http://www.dlr.de/eoc/en/desktopdefault.aspx/tabid-11932/20674_read-48811/
Here is a simple Python code to extract the central strip from Landsat 7 imagery (SLC-off), that is not affected by the SLC failure. The algorithm shrinks the striping zones through a morphological filter (erosion) and creates a new shapefile AOI that extracts the desired raster extent without striping effects. The code is based on Python for ArcGIS (arcpy) – so you require a ArcGIS license.
- Loop through all Landsat 7 data folders
- Stack bands for each image
- Create a mask
- Erode the mask by 20 pixels
- Convert the mask to polygon
- Create a minimum bounding box
- Clip the original raster through the bbox
from arcpy.sa import *
# Environment settings (Activate Spatial Analyst, Overwrite Outputs allowed and TIFF compression is LZW)
arcpy.env.overwriteOutput = True
arcpy.env.compression = 'LZW'
# this is your main directory with all unzipped Landsat datasets
rootdir = "D:\\DATA\\Landsat7\\"
# create scratch folder "temp"
temp = "D:\\DATA\\temp\\"
# loop through directory with all unzipped Landsat 7 folders
for files in os.listdir(rootdir):
files = os.path.join(rootdir, files)
# for each loop the subdir "files" is now the current workspace
# (e.g. LE71520322015157-SC20160224113319) that contains the Landsat bands
arcpy.env.workspace = files
rasters = arcpy.ListRasters("*", "TIF")
# create empty array
stack_liste = 
# loop through all rasters in subdir
for raster in rasters:
image = arcpy.Raster(raster)
name = image.name
index = name.split("_")
# fill up the array only with the actual spectral bands
sr = "_sr_band"
if sr in raster:
# now stack all bands within the array
stack_name = files + "\\" + index + "_stack.tif"
# convert the image stack to a mask by logical operation with an absurd value that will result in an output "0"
con = EqualTo(stack_name, 123456789)
# now shrink the raster mask with value "0" by 20 pixels
shrink = temp + "shrink"
shrinking = Shrink(con, 20, 0)
zone = temp + "zone.shp"
bbox = temp + "bbox.shp"
# conver the shrunk mask to polygon and create a minimum bounding box
arcpy.RasterToPolygon_conversion(shrink, zone, "NO_SIMPLIFY", "VALUE")
arcpy.MinimumBoundingGeometry_management(zone, bbox, "RECTANGLE_BY_WIDTH", "NONE")
# now use that bounding box as a mask to cut out the central nadir strip from the original stack
# Final result
extract = files + "\\" + index + "_aoi.tif"
ExtractByMask = arcpy.sa.ExtractByMask(stack_name, bbox)
Our book “Remote Sensing and GIS for Ecologists – Using Open Source software” is now available. First editor copies arrived already and it looks pretty good. Great to have finally a copy on our desks after all the writing, testing and editing! We hope that you enjoy it as much as we do and that it helps you working with remote sensing and GIS in your research topics.
You can order it here.
All practical examples in this book rely on OpenSource software and freely available data sets. Quantum GIS (QGIS) is introduced for basic GIS data handling, and in-depth spatial analytics and statistics are conducted with the software package R.
Readers will learn how to apply remote sensing within ecological research projects, how to approach spatial data sampling and how to interpret remote sensing derived products. We discuss a wide range of statistical analyses with regard to satellite data as well as specialised topics such as time-series analysis. Extended scripts on how to create professional looking maps and graphics are also provided.
This book is a valuable resource for students and scientists in the fields of conservation and ecology interested in learning how to get started in applying remote sensing in ecological research and conservation planning.
check the table of content here: http://book.ecosens.org/content/
PostGIS is the spatial extension of the open source database management system PostgreSQL. It helps you to manage your data (vector and raster) within a coherent geodatabase through a variety of spatial functions. Having a spatial database, the times of data clutter and messiness are over, especially when you are dealing with big data. Initially PostGIS was created to for the handling of vector data only. However, during the recent years more and more raster handling functionalities were introduced. For a complete overview of spatial raster operators, have a look at: http://postgis.net/docs/manual-2.1/RT_reference.html
Download and install PostgreSQL and PostGIS
Download PostgreSQL from here: http://www.postgresql.org/download/
The installer for PostgreSQL includes the PostgreSQL server, pgAdmin III; a GUI for managing and developing your databases, and StackBuilder; a package manager that can be used to download and install additional PostgreSQL applications and drivers. From the StackBuilder GUI, select Spatial Extensions and install the respective PostGIS 2.2 Bundle for PostgreSQL.
Create a new spatial database
In pgAdmin, create a new database (right click: New Database):
and the spatial extension postgis (right click on Extensions: New Extension):
This will create a first table within your DB: spatial_ref_sys that contains the coordinate systems, map projections and the spatial indeces.
Set up Python
Python provides awesome functionality for the automated raster processing within PostGIS. Automatization is necessary especially when you deal with a lot of data and iterative processes. Python scripting is also needed as the pgAdmin GUI does not support the access of all functions.
Download Python 2.7 from here: https://www.python.org/downloads/
Psycopg2 is a Python library that accesses the objects of the PostgreSQL server and allows the execution of PostGIS commands from Python.
Download psycopg2 from here: http://www.stickpeople.com/projects/python/win-psycopg/2.6.1/psycopg2-2.6.1.win32-py2.7-pg9.4.4-release.exe
PostGIS scripting with Python
Import the Python libraries:
import sys, os
Set up input path and a loop that goes through all TIFs in the directory:
input_path = "C:\\Data\\Raster\\"
for raster in os.listdir(input_path):
name = raster.split(".tif")
raster = os.path.join(input_path, raster)
Connect to the PostgreSQL server:
os.environ['PATH'] = r';C:\Program Files\PostgreSQL\9.4\bin'
os.environ['PGHOST'] = 'localhost'
os.environ['PGPORT'] = '5432'
os.environ['PGUSER'] = 'postgres'
os.environ['PGPASSWORD'] = 'postgres'
os.environ['PGDATABASE'] = 'raster_database'
rastername = str(name)
rasterlayer = rastername.lower()
conn = psycopg2.connect(database="raster_database", user="postgres", host="localhost", password="postgres")
cursor = conn.cursor()
Import each raster through raster2pgsql function (coordinate system epsg code is set to 32633 UTM):
cmds = 'raster2pgsql -s 32633 -t 2000x2000 "' + raster + '" |psql'
Now run any PostGIS command you like. In this example we run rescale the raster to 250m spatial resolution and reproject it from UTM 33N to WGS84 (epsg code 4326). At the end, the raster may be exported locally to *.hex data format. The export is optional, we could also convert the raster to CSV or numpy array.
sql = "UPDATE " + rasterlayer + " SET rast = ST_Rescale(rast, 250, 'Near'); \
UPDATE " + rasterlayer + " SET rast = ST_Transform(ST_SetSRID(rast,32633),4326);"
rql = "COPY (SELECT encode(ST_AsTIFF(rast), 'hex') AS tif FROM " + rasterlayer + ") TO 'C:/Users/Data/" + rasterlayer + ".hex';"