Browse Source

Work with maps

Petra Lamborn 3 years ago
parent
commit
6aec62f615
2 changed files with 23 additions and 0 deletions
  1. 2
    0
      .gitignore
  2. 21
    0
      maps.R

+ 2
- 0
.gitignore View File

@@ -2,3 +2,5 @@
2 2
 .Rhistory
3 3
 .RData
4 4
 .Ruserdata
5
+
6
+shapefiles/

+ 21
- 0
maps.R View File

@@ -0,0 +1,21 @@
1
+library(rgdal)
2
+library(rmapshaper)
3
+
4
+sf <- readOGR(dsn = "shapefiles/statsnzstatistical-area-2-2018-generalised-SHP/")
5
+
6
+plot(sf, xlim=c(1750000, 1760000), ylim=c(5430000, 5440000))
7
+# insf <- ms_innerlines(sf)
8
+
9
+ssf1 <- ms_simplify(sf)
10
+plot(ssf1, xlim=c(1750000, 1760000), ylim=c(5430000, 5440000))
11
+
12
+ssf2.5 <- ms_simplify(sf, 0.025)
13
+plot(ssf2.5, xlim=c(1750000, 1760000), ylim=c(5430000, 5440000))
14
+
15
+ssf2 <- ms_simplify(sf, 0.01)
16
+plot(ssf2, xlim=c(1750000, 1760000), ylim=c(5430000, 5440000))
17
+
18
+ssf3 <- ms_simplify(sf, 0.002)
19
+plot(ssf3, xlim=c(1750000, 1760000), ylim=c(5430000, 5440000))
20
+
21
+writeOGR(ssf2, dsn = "shapefiles/sa2001/", layer = "SA2", driver="ESRI Shapefile")