# AMP planner 2, Ubuntu amd64 deb package

I picked up my UAV work again. However, I was annoyed by the fact that the standard debian package of the APM planner 2 does not install nicely on the latest Ubuntu 14.04 LTS install because of the upgraded openscenegraph99 libraries (which mess up dependencies).

As such I changed the control file on the original debian package, repackaged it and giving some softlinking the package should installs nicely without triggering any errors in your package manager.

!! The nightly builds of the APM planner now address the above issue. I encourage you to download a nightly build or latest release when using Ubuntu 14.04. My bitbucket repository is offline as of now. !!

Awaiting an update of the official APM planner deb file on the main site you can download my file (at your own discretion) and read the installation instructions here: https://bitbucket.org/khufkens/apm-planner-fix.

# DaymetR, an official Daymet R package

I have described my DaymetR scripts in previous posts (here and here). However, some communication with Michele Thornton a DAYMET admin at Oak Ridge National Laboratories brought to light some issues in the way I handled specifying a region of interest. Mainly, the reprojection of the netcdf ancillary files at the edges. This is a typical issue when reprojecting raster data. As a solution I requested a shape file of the grid tiles instead of a raster and Michele kindly provided.

After cleaning up my code I also decided to wrap both the single pixel location as well as the gridded data extraction tools in a proper R package!! The package also includes the map by default so no additional data needs to be downloaded. However, I do provide the shapefile of the DAYMET grid tiles separately.

You can download my first R package on my bitbucket page linked to on my software page or by following this link. I validated the code after the recent changes in server setup at DAYMET, and all seems to be fine. Please report any bugs if you find any.

# Basic GIS in R

Recently I had to help out a colleague with processing some spatial data in R. The overall goal was to find landscape parameters (topography, soil characteristics, etc.) within the neighbourhood of a flux tower.

The below  code gives a short introduction on how to extract data from both raster and shapefiles (vector data), very common operations .  I will add more tips and tricks as I come across them.

# Load libraries.
# For raster data
require(raster)

# For vector data
require(sp)

# Set flux tower coordinates.
lat= 45.2041
lon=-68.7402

# Define lat / lon projection.
lat_lon <- CRS("+init=epsg:4326")

# Define UTM projection.
utm <- CRS( "+proj=utm +zone=19 +north +ellps=WGS84 +datum=WGS84 +no_defs")

# Read in the coordinates and assign them a projection, # otherwise they remain just 'numbers'
location <- SpatialPoints(cbind(lon,lat), lat_lon)

# Convert to utm using the above projection string
# using spTransform.
location_utm <- spTransform(location, utm)

# Load raster Digital Terrain Map (DTM) data.
# If the raster data has no projection,
# you will have to assign a projection.
# I assume the file has a projection.
dtm <- raster('DTM.tif')

# Relative height of the location of the tower.
dtm_data <- extract(dtm,location_utm)

# Assign projection to the soils.shp file
# if not provided.
proj4string(soils) <- utm

# Extract soil polygon attributes.
soil_attributes <- over(location_utm,soils)

Yesterday I updated my laptop from Ubuntu 12.04 LTS to the latest release 14.04 LTS (Trusty Thar). Overall the experience is very pleasant. I noticed that the interface is snappier, bootup is as fast (It’s difficult to notice any differences on a fast SSD drive). What I did not like was the removal of some functionality in the file manager, mainly splitting the file manager window into two columns. This has been a sore point for many users but there are work arounds of it really messes with your workflow. I’ll give it a try and go without for a while. Also some of my favourite themes don’t work anymore. I now use the Numix theme as a subsitute.

I also did some counting and I figured out that I’ve spend most of my research career (approaching 10 years) using Ubuntu, starting with their first release 4.10 (warty warthog). More so, aside from some graphics work for which I used a Mac I’ve been only using Linux for research and day to day needs, and never regretted making this move. With Ubuntu moving into tablet territory I foresee some exciting times in the linux (open-source) community.

# DaymetR – gridded data extension

Short recap: Daymet is a collection of algorithms and computer software designed to interpolate and extrapolate from daily meteorological observations to produce gridded estimates of daily weather parameters - as concisely described on the Daymet website.

I’m extensively using daily meteorological data to drive a grassland growth model and quick and easy access to this data is therefore key. Although I previously coded a script to deal with single pixel data extraction I now updated my DaymetR package to include gridded (tiled) data downloads through the specification of a region of interest (top left / bottom right) or single point location.

The script has the following syntax:

download.Daymet.tiles(lat1=36.0133,
lon1=-84.2625,
lat2=NA,
lon2=NA,
start_yr=1980,
end_yr=2012,
param="ALL")

If only the first set of coordinates is provided (lat1 / lon1) the tile in which these reside is downloaded. If your location / region of interest [defined by a top left (lat1 / lon1) and bottom right (lat2 / lon2) coordinate set] falls outside the scope of the DAYMET data coverage a warning is issued. All tiles covering the region of interest are downloaded for their respective parameters, e.g. minimum and maximum temperature (see bitbucket documentation for details).

This final addition is a spatial extension of the previous code, serving primarily the spatial scaling needs of my modelling exercises. All code can be found on through my software page or by following this direct link to my bitbucket page. I hope this might serve other people in the R community.