Blog Archives

Download all Documents from Google Drive with R

March 17, 2014
By
Download all Documents from Google Drive with R

(This article was first published on theBioBucket*, and kindly contributed to R-bloggers) A commentator on my blog recently asked if it is possible to retrieve all direct links to your Google Documents. And indeed it can be very easily done with R, just like so: # you'll need RGoogleDocs (with RCurl dependency..) install.packages("RGoogleDocs", repos = "http://www.omegahat.org/R", type="source") library(RGoogleDocs) gpasswd...

Read more »

Use Case: Make Contour Lines for Google Earth with Spatial R

March 3, 2014
By
Use Case: Make Contour Lines for Google Earth with Spatial R

Here's comes a script I wrote for creating contour lines in KML-format to be used with Google Earth https://github.com/gimoya/theBioBucket-Archives/blob/master/R/r_contours_for_google_earth.RIf you want to check or just use the datasets I created for t...

Read more »

Use GDAL from R Console to Split Raster into Tiles

March 1, 2014
By
Use GDAL from R Console to Split Raster into Tiles

When working with raster datasets I often encounter limitations caused by the large size of the files. I thus wrote up a little R function that invokes gdal_translate which would split the raster into parts.The screenshot to the left shows a raster in QGIS that was split into four parts with the below script.## get filesnames...

Read more »

Use Case: Spatial R & Google Earth for Terrain Analyses

February 5, 2014
By
Use Case: Spatial R & Google Earth for Terrain Analyses

I'd like to share code that uses spatial R and Google Earth for terrain analyses. In this example I took SRTM data at 1" resolution from http://www.viewfinderpanoramas.org/dem3.html#alps read it into R did a little processing and finally wrapped it up ...

Read more »

R GIS: Polygon Intersection with gIntersection{rgeos}

September 16, 2013
By
R GIS: Polygon Intersection with gIntersection{rgeos}

A short tutorial on doing intersections in R GIS. gIntersection{rgeos} will pick the polygons of the first submitted polygon contained within the second poylgon - this is done without cutting the polygon's edges which cross the clip source polygon. For the function that I use to download the example data, url_shp_to_spdf() please see HERE. library(rgeos)library(dismo)URLs...

Read more »

Batch Downloading Zipped Shapefiles with R

September 16, 2013
By

Here's a function I use to download multiple zipped shapefiles from url and load them to the workspace:URLs "http://gis.tirol.gv.at/ogd/umwelt/wasser/wis_tseepeicher_pl.zip")url_shp_to_spdf require(rgdal) wd td setwd(td) temp download.file(URL, temp) unzip(temp) shp lyr y names(y)...

Read more »

Follow Up on Spatial Overlays with R – Getting Altitude for a Set of Points

September 16, 2013
By
Follow Up on Spatial Overlays with R – Getting Altitude for a Set of Points

A short follow up on a previous post on spatial overlays with R. library(sp)library(dismo)# some addresses in Austriapts # make pts spatialcoords spdf_pts # assign CRS/projection (which is WGS 1984)crs proj4string(spdf_pts) # spatial data to extract (altitude)alt # convert alt from raster to grid (needed for over::sp)# and assign CRS (which is the same...

Read more »

Loading Multiple Shapefiles to the R-Console Simultaneously

September 10, 2013
By

A quick tip on how to load multiple shapefiles (point shapefiles, i.e.) to the R console in one go:library(sp)# get all files with the .shp extension from working directory setwd("D:/GIS_DataBase/GIS_Tirol/Tirol_Verbreitungskarten/Verbreitungs_Daten")shps # the assign function will take the string representing shp and turn it into a variable# which holds the spatial points datafor (shp in shps) assign(shp, readShapePoints(shp))# ...done

Read more »

Text Mining with R – Comparing Word Counts in two Text Documents

August 19, 2013
By

Here's what I came up with to compare word counts in two pieces of text. If you got any idea, I'd love to learn about alternatives!## a function that compares word counts in two textswordcount ...

Read more »

Spatial Overlays with R – Retrieving Polygon Attributes for a Set of Points

June 19, 2013
By

A short tutorial for spatial overlays using R-GIS..library(sp)library(dismo)# spatial dataalt gadm # viewplot(alt)plot(gadm, add=T)# some addressespts # make it spatialcoords spdf_pts # assign CRS/projectionproj4string(spdf_pts) # check datastr(spdf_pts)# plot it on topplot(spdf_pts, cex = 2, col = 2, add = T)# do an intersection (points in polygon)# yielding the polygon's attribute dataover(spdf_pts, gadm)

Read more »