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

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

主站蜘蛛池模板: 金溪县| 永顺县| 鱼台县| 萝北县| 朝阳市| 武强县| 冷水江市| 竹北市| 广丰县| 新乡市| 库伦旗| 界首市| 桃江县| 读书| 桃江县| 乐安县| 泸溪县| 广元市| 沁水县| 新安县| 郯城县| 富顺县| 南华县| 客服| 台安县| 黄平县| 大新县| 普兰县| 濮阳市| 东宁县| 和龙市| 太仆寺旗| 无为县| 巴彦县| 新建县| 海晏县| 贡觉县| 翼城县| 深州市| 水城县| 封丘县|