官术网_书友最值得收藏!

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

主站蜘蛛池模板: 盐源县| 都匀市| 连江县| 浠水县| 大关县| 乌恰县| 刚察县| 平利县| 嵩明县| 东莞市| 望城县| 九江市| 林西县| 米易县| 休宁县| 沙田区| 呼伦贝尔市| 临江市| 承德市| 长沙市| 苗栗市| 东港市| 旺苍县| 安宁市| 陇南市| 繁峙县| 雅江县| 乌拉特中旗| 拜城县| 洛宁县| 沂水县| 内乡县| 湾仔区| 江达县| 石嘴山市| 金山区| 广宁县| 翼城县| 霍州市| 滦南县| 井陉县|