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

Importing point data from Excel

We have many arbitrary measures collected for different districts of Bangladesh along with their point coordinates; these measures contain both numeric and categorical values.

Now, we will import this data into R using read.csv() as follows:

bd_val = read.csv("F:/Hands-on-Geospatial-Analysis-Using-R-and-QGIS/Chapter02/Data/r_val.csv", stringsAsFactors = FALSE)

 We check the structure of this dataset bd_val using str():

str(bd_val)

We get the following output:

We see that the type of bd_val is dataframe. Now, we convert this into SpatialPointsDataFrame by using coordinates() and by specifying which columns contain the longitude and latitude of these points. 

# Convert it into SpatialPointsDataframe
coordinates(bd_val) = c("lon", "lat")
str(bd_val)

Now, plot this using plot():

plot(bd_val, col = "blue", pch = 19)

Now, we get the following map with blue dot for each point:

主站蜘蛛池模板: 平江县| 武隆县| 东阳市| 舞阳县| 彭州市| 潞城市| 文山县| 宜章县| 绍兴市| 水城县| 和顺县| 昌黎县| 潜江市| 阿克陶县| 绍兴市| 平舆县| 讷河市| 文成县| 南昌市| 克山县| 浪卡子县| 保亭| 乳山市| 丽水市| 诸暨市| 习水县| 临夏县| 远安县| 嘉义县| 大宁县| 芒康县| 闽清县| 垫江县| 旺苍县| 鞍山市| 鄂尔多斯市| 海伦市| 抚远县| 宁武县| 明星| 青川县|