November 2018
Beginner to intermediate
354 pages
6h 59m
English
Here, we'll learn how to clip spatial points to a shapefile. For example, we have many data points over many places of Bangladesh and we want to clip these data points to the shapefile of Dhaka, named dhaka.shp. In this example, we have a CSV file, arbitrary_indicator.csv, which has two columns, lon and lat, containing the longitude and latitude of these points, respectively. To achieve our objective, we can take the following steps.
First, read the CSV file and then use coordinates() to turn it into a spatial object that R can recognize. In doing so, indicate the longitude and latitude fields followed by ~:
points = read.csv("F:/Hands-on Geospatial-Analysis-Using-R-and- QGIS/Chapter04/Data/arbitrary_indicator.csv")coordinates(points) ...Read now
Unlock full access