Lade Postleitzahl-Gebiete und R-Erweiterungen
library(rgdal)
## Loading required package: sp
## rgdal: version: 1.3-1, (SVN revision 747)
## Geospatial Data Abstraction Library extensions to R successfully loaded
## Loaded GDAL runtime: GDAL 2.2.3, released 2017/11/20
## Path to GDAL shared files: /usr/share/gdal/2.2
## GDAL binary built with GEOS: TRUE
## Loaded PROJ.4 runtime: Rel. 4.9.3, 15 August 2016, [PJ_VERSION: 493]
## Path to PROJ.4 shared files: (autodetected)
## Linking to sp version: 1.2-7
library(lattice)
library(latticeExtra)
## Loading required package: RColorBrewer
library(rgeos)
## rgeos version: 0.3-27, (SVN revision 560)
## GEOS runtime version: 3.6.2-CAPI-1.10.2 4d2925d6
## Linking to sp version: 1.2-7
## Polygon checking: TRUE
plz_poly <- readOGR("postleitzahlengebiete_mecklenburg-vorpommern.kml")
## OGR data source with driver: LIBKML
## Source: "/home/matthias/plz_aggregation/postleitzahlengebiete_mecklenburg-vorpommern.kml", layer: "postleitzahlengebiete_mecklenburg-vorpommern"
## with 190 features
## It has 13 fields
plz <- as.numeric(as.character(plz_poly$postleitzahl))
# wähle alle PLZ in Rostock
rostock_poly <- plz_poly[plz %in% c(18055, 18057, 18059, 18069, 18106, 18107, 18109, 18119, 18146, 18147, 18181, 18182),]
## Projiziere Koordinaten nach Gauß-Krüger (Zone 3)
proj4string(plz_poly)
## [1] "+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"
rostock_poly_gk3 <- spTransform(rostock_poly, CRSobj = CRS("+init=epsg:31467"))