- Hands-On Geospatial Analysis with R and QGIS
- Shammunul Islam
- 136字
- 2021-06-10 18:44:27
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:

推薦閱讀
- 大學(xué)計算機基礎(chǔ):基礎(chǔ)理論篇
- Machine Learning for Cybersecurity Cookbook
- Visual C# 2008開發(fā)技術(shù)實例詳解
- 數(shù)據(jù)庫原理與應(yīng)用技術(shù)學(xué)習(xí)指導(dǎo)
- 快學(xué)Flash動畫百例
- 新編計算機圖形學(xué)
- 計算機與信息技術(shù)基礎(chǔ)上機指導(dǎo)
- Silverlight 2完美征程
- 嵌入式GUI開發(fā)設(shè)計
- Windows安全指南
- Building Google Cloud Platform Solutions
- 常用傳感器技術(shù)及應(yīng)用(第2版)
- Visual Basic項目開發(fā)案例精粹
- Hands-On Deep Learning with Go
- 網(wǎng)管員世界2009超值精華本