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

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

主站蜘蛛池模板: 井研县| 康保县| 乡宁县| 大化| 大连市| 云和县| 郴州市| 彭州市| 庐江县| 通榆县| 乐平市| 阜南县| 容城县| 砚山县| 榕江县| 瑞昌市| 盐山县| 苏尼特右旗| 固始县| 山阴县| 太谷县| 南部县| 逊克县| 巢湖市| 长武县| 江西省| 合作市| 济南市| 色达县| 东台市| 静海县| 怀化市| 龙胜| 三门峡市| 南华县| 赣榆县| 崇州市| 咸阳市| 孟州市| 海丰县| 两当县|