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

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

主站蜘蛛池模板: 辽源市| 迁西县| 青田县| 偃师市| 新郑市| 开鲁县| 布拖县| 晋城| 来凤县| 容城县| 贵港市| 连江县| 岗巴县| 金坛市| 都江堰市| 吉木萨尔县| 泰顺县| 香格里拉县| 瑞昌市| 常德市| 宣化县| 积石山| 尼勒克县| 怀远县| 泗阳县| 太和县| 普兰店市| 攀枝花市| 斗六市| 邮箱| 灌南县| 时尚| 依兰县| 海门市| 大同县| 外汇| 宝兴县| 双柏县| 黎川县| 平阳县| 隆子县|