Commit b5cf05b7 authored by Weigert, Andreas's avatar Weigert, Andreas
Browse files
parents 223601eb 7b2124ed
......@@ -8,7 +8,7 @@ editor_options:
# Practicals for geographic data
```{r install packages}
install.packages("sp", "rgdal", "osmar", "lubridate")
install.packages("sp", "rgdal", "osmdata", "lubridate", "dplyr")
```
......@@ -27,7 +27,7 @@ library(sp)
library(rgdal)
#read the shapefile
ger.shp <- readOGR("../data/DE_Admin_Geodata/VG250_Kompakt/", "VG250_L") #lines
ger.shp <- readOGR(dsn = "../data/DE_Admin_Geodata/VG250_Kompakt/VG250_L.shp", layer = "VG250_L") #lines
#the attribute AGZ contains the type of the boundary (AGZ = 'Art der Grenze')
table(ger.shp$AGZ)
......@@ -42,7 +42,7 @@ lines(ger.shp[ger.shp$AGZ==4, ], col=4) #Kreise
```{r load German states as polygons}
#read teh shapefile
ger.shp <- readOGR("../data/DE_Admin_Geodata/VG250_Ebenen/", "VG250_LAN")
ger.shp <- readOGR("../data/DE_Admin_Geodata/VG250_Ebenen/VG250_LAN.shp", "VG250_LAN")
#basic plot of the data - looks similar to previous plot
plot(ger.shp)
......@@ -137,26 +137,35 @@ There is a special [Overpass API](https://wiki.openstreetmap.org/wiki/Overpass_A
to retrieve much data from the database.
```{r accessing OpenStreetMap data}
library(osmar)
library(osmdata)
library(dplyr)
erba_data <- get_osm(x = center_bbox(center_lon = 10.86832,
center_lat = 49.90300,
width=300,
height=300),
source = osmsource_api(url = "https://api.openstreetmap.org/api/0.6/"))
#helps to get the bounding box
osmar::center_bbox(center_lon = 49.90317, center_lat = 10.86961, width = 5000, height = 5000)
#plot the data
plot(as_sp(erba_data, what = "lines"))
points(as_sp(erba_data, what = "points"), pch=16, col=2, cex=0.5)
axis(1)
axis(2)
erba_buildings <- opq(bbox = c(10.86825, 49.90180, 10.87097, 49.90454)) %>%
add_osm_feature(key = "building", value = c("yes", "university", "apartments")) %>%
osmdata_sp ()
#display the data stored for each object
View(erba_data$nodes$attrs)
erba_streets <- opq("Bamberg") %>%
add_osm_feature(key = "highway", value = c("residential")) %>%
osmdata_sp ()
erba_water <- opq("Bamberg") %>%
add_osm_feature(key = "waterway", value = c("stream")) %>%
#add_osm_feature(key = "water", value = c("canal", "river")) %>%
osmdata_sp ()
#display the tags stored for each object (contain the geographic meaning)
View(erba_data$nodes$attrs)
#head(erba_data)
#plot the data
plot(erba_buildings$osm_polygons)
lines(erba_streets$osm_lines, col=2, lwd=2)
lines(erba_water$osm_lines, col=4)
#display the data stored for each object
str(erba_buildings, max.level = 3)
```
# Practicals for the date and time handling
......
PROJCS["ETRS_1989_UTM_Zone_32N",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",9.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0]]
\ No newline at end of file
PROJCS["ETRS_1989_UTM_Zone_32N",GEOGCS["GCS_ETRS_1989",DATUM["D_ETRS_1989",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",500000.0],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",9.0],PARAMETER["Scale_Factor",0.9996],PARAMETER["Latitude_Of_Origin",0.0],UNIT["Meter",1.0],AUTHORITY["EPSG",25832]]
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment