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

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:

主站蜘蛛池模板: 定兴县| 绍兴市| 额尔古纳市| 澄城县| 江源县| 聂拉木县| 南澳县| 武宁县| 德惠市| 绵阳市| 万山特区| 石林| 巴里| 沽源县| 东莞市| 车险| 和田县| 江达县| 丰顺县| 尼勒克县| 观塘区| 全南县| 容城县| 加查县| 田东县| 毕节市| 河北区| 铜鼓县| 吉林省| 龙里县| 巴彦县| 洛宁县| 丹棱县| 临汾市| 油尖旺区| 鸡泽县| 若尔盖县| 滦平县| 师宗县| 同江市| 恭城|