University of Wisconsin–Madison

Tag: GIS

Distance to a lake

How far are you from a lake? Living in Wisconsin, I wanted to know. There’s a lot of lakes in Wisconsin, but it was hard to visualize their distribution. Step 1) Download the high-resolution National Hydrography Dataset for Wisconsin (I host this locally as a shapefile). I only kept lakes with a surface area larger than …

Extracting polygon areas in R

Suppose I have a shapefile (lakes.shp) which consists of 5 polygons (Figure 1a). library(raster) lakes = shapefile(’lakes.shp’) plot(lakes, col=’dodgerblue’,main=’a) lakes’,lty=0) The shapefile is stored as a SpatialPolygonsDataFrame. The data underlying these polygons can be viewed with: lakes@data There is a column called SHAPE_Area, which is the area of each polygon. Now let’s say, we want …