- 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:

推薦閱讀
- Instant Raspberry Pi Gaming
- PPT,要你好看
- 工業機器人技術及應用
- R Data Mining
- DevOps:Continuous Delivery,Integration,and Deployment with DevOps
- 大數據驅動的機械裝備智能運維理論及應用
- Python:Data Analytics and Visualization
- Mastering GitLab 12
- ESP8266 Robotics Projects
- Hands-On Dashboard Development with QlikView
- 基于RPA技術財務機器人的應用與研究
- 智慧未來
- 納米集成電路制造工藝(第2版)
- 運動控制器及數控系統的工程應用
- Hadoop大數據開發基礎