-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwarsaw_district_shapefile.R
More file actions
33 lines (24 loc) · 1.14 KB
/
warsaw_district_shapefile.R
File metadata and controls
33 lines (24 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# preparing shapefile for warsaw distrcits
library("rgdal")
library("maptools")
library("rgeos")
library("stringi")
# data downloaded from
# http://www.codgik.gov.pl/index.php/darmowe-dane/prg.html
# WARNING - this file is huge! 400Mb to download, 700Mb after unzipping
shp <- readShapePoly("~/Pobrane/PRG_jednostki_administracyjne_v8/jednostki_ewidencyjne.shp",
proj4string = CRS("+init=epsg:2180"))
shp@data$jpt_nazwa_ <- stri_encode(shp@data$jpt_nazwa_,
from = "windows-1250", to = "UTF-8")
# subset warsaw districts
shp <- shp[which(substr(shp@data$jpt_kod_je, 8, 8) == 8), ]
# remove unnecessary data
shp <- shp[, c("jpt_kod_je", "jpt_nazwa_")]
names(shp@data) <- c("kod", "nazwa")
shp@data <- transform(shp@data, kod = as.character(kod), nazwa = as.character(nazwa))
# transform coordinate system
shp <- spTransform(shp, CRS("+proj=longlat +datum=WGS84"))
# add information about location acording to river (left/right bank)
shp@data$bank <- c("r", "r", "l", "l", "l", "l", "r", "r", "r", "l", "l", "r",
"l", "r", "l", "l", "l", "l")
saveRDS(shp, "warsaw_districts_shp.RDS")