- Hands-On Geospatial Analysis with R and QGIS
- Shammunul Islam
- 189字
- 2021-06-10 18:44:27
Plotting point data
Location is a point characterized by its coordinates. Point data comprises attributes of a location or data collected on a parameter from different points. Shapefile is a popular data format for vector data. In R, the sp package loads shapefile as SpatialPoints and if it contains attributes, it is saved as SpatialPointsDataFrame. We can import a shapefile into R, using the readOGR() function of the sp package. We have to provide the path to the shapefile as the first parameter for the readOGR() function and the name of the shapefile is the second parameter. Here, we have to provide the name of the shapefile without the .shp extension. So, if we want to import a shapefile containing points, we can do so by writing the following:
# SpatialPoints
library(sp)
library(rgdal)
library(maptools)
map = readOGR("F:/Hands-on-Geospatial-Analysis-Using-R-and-QGIS/Chapter 02/Data","indicator")
plot(map)
We see the following map, which just shows point data as a plus point indicating different districts in Bangladesh:

Now, let's check the class of this data map:
class(map)
The class is SpatialPointsDataFrame.
- 輕松學(xué)C語言
- 精通MATLAB圖像處理
- Practical Data Wrangling
- 教父母學(xué)會(huì)上網(wǎng)
- Julia 1.0 Programming
- 樂高創(chuàng)意機(jī)器人教程(中級(jí) 下冊(cè) 10~16歲) (青少年iCAN+創(chuàng)新創(chuàng)意實(shí)踐指導(dǎo)叢書)
- PHP開發(fā)手冊(cè)
- Blender Compositing and Post Processing
- Cloudera Administration Handbook
- Excel 2007技巧大全
- 單片機(jī)C語言應(yīng)用100例
- Windows Server 2008 R2活動(dòng)目錄內(nèi)幕
- Linux嵌入式系統(tǒng)開發(fā)
- R Data Analysis Projects
- 無人駕駛感知智能