I needed to create a raster map layer with a weighted random sample of all raster cells, using the percentage of crop land as weight. I couldn’t find a function to create such a weighted sample, so I decided to create a script to do this for me. Continue reading Creating a raster layer with a weighted random sample of points (or, my first attempt to create a python script)
The Multivariate Environmental Similarity Surfaces (MESS) is an index that represents how similar a point in space is to a reference set of points, with respect to a set of predictor variables (Elith et al 2010). The function was first implemented as part of the Maxent software package, and is also available in the dismo package for R (see also here and here).
The latter works well on small and medium sized data sets. However, they take a long time to run on larger data sets, e.g., when working with 1km² raster grids covering eastern Africa. I therefore wrote a small R script to compute MESS in GRASS GIS. Continue reading Multivariate Environmental Similarity Surfaces (MESS) index in GRASS GIS
I often run R from within GRASS GIS. For example using R as a scripting language to automate GIS analysis. Or to use statistical models in R on spatial data in GRASS.
I used to open R in the terminal. However, I am using more and more RStudio instead. This has one drawback. When opening RStudio in the terminal (or any other program for that matter), you cannot use that command prompt anymore. Continue reading Start R inside GRASS but keep the terminal prompt
GRASS GIS is a very powerfull GIS offering an extensive set of tools for geospatial data management and analysis, image processing, and spatial modeling. The possibility to directly interact with R further improves the geospatial analysis capabilities of GRASS (see R Spatial View). Continue reading R/GRASS connection: more than the sum of its parts
Earlier I wrote about the custom STRJOIN function in OpenOffice. A very handy function when you need to combine all values in a row or column (or combination of the two), separated by a delimiter.
In R this is (also) very easy Continue reading Combining text from data frame in one text string in R
I have never given it a though, but there is apparently a limit to the length of file names that can be handled by Windows Explorer of Windows XP. I found out when trying to copy my Zotero folder to a computer with Windows XP. I was getting error message of folders that could not be copied, suggesting that my HD was full. I checked a few of these folders and they all contained one or more files with very long file names (>250 characters). Continue reading Finding and renaming long file names with R
In this post I was trying to find a way to get a list of GRASS data layers in R. The problem is running the GRASS function ‘g.list’ from R (using system or execGRASS from the spgrass6 package) gives a vector which can not be easily handled in R (i.e., it is not a nice vector with one layer name per vector element).
Finding the solution was a nice exersize in using the R functions gsub() and strsplit(), but today I realized that there is solution that is not only easier but also better and more flexible. Continue reading Using the GRASS command g.mlist in R