Browse Source

Merge branch 'master' of petras.space:petra/commute

Petra Lamborn 3 years ago
parent
commit
055137db93
1 changed files with 6 additions and 4 deletions
  1. 6
    4
      maps.R

+ 6
- 4
maps.R View File

@@ -1,7 +1,8 @@
1 1
 library(rgdal)
2 2
 library(rmapshaper)
3 3
 
4
-sf <- readOGR(dsn = "shapefiles/statsnzstatistical-area-2-2018-generalised-SHP/")
4
+# sf <- readOGR(dsn = "shapefiles/statsnzstatistical-area-2-2018-generalised-SHP/")
5
+sf <- readOGR(dsn = "shapefiles/SA2-2018-WGS/")
5 6
 nrow(sf@data)
6 7
 
7 8
 plot(sf, xlim=c(1480000, 1510000), ylim=c(5150000, 5180000))
@@ -23,14 +24,15 @@ ssf3 <- ms_simplify(sf, 0.002, keep_shapes=TRUE)
23 24
 plot(ssf3, xlim=c(1480000, 1510000), ylim=c(5150000, 5180000))
24 25
 nrow(ssf3@data)
25 26
 
26
-writeOGR(ssf2.5, dsn = "shapefiles/sa20025/", layer = "SA2", driver="ESRI Shapefile")
27
+writeOGR(ssf2.5, dsn = "shapefiles/sa20025WGS/", layer = "SA2", driver="ESRI Shapefile")
27 28
 
28 29
 ssf3b <- ms_simplify(sf, 0.002, keep_shapes=FALSE)
29 30
 plot(ssf3b, xlim=c(1480000, 1510000), ylim=c(5150000, 5180000))
30 31
 nrow(ssf3b@data)
31 32
 
33
+ci <- sf@data$SA22018__1 != "Chatham Islands"
32 34
 head(ssf2.5@data)
33 35
 laper <- (sf@data$LAND_AREA_ / sf@data$AREA_SQ_KM)
34 36
 sf@data$SA22018__1[laper > 0.1 & laper < 0.4]
35
-plot(ssf2.5[laper > 0.1,])
36
-writeOGR(ssf2.5[laper > 0.1,], dsn = "shapefiles/sa20025fil/", layer = "SA2", driver="ESRI Shapefile")
37
+plot(ssf2.5[(laper > 0.1) & ci,])
38
+writeOGR(ssf2.5[(laper > 0.1) & ci,], dsn = "shapefiles/sa20025WGSfil/", layer = "SA2", driver="ESRI Shapefile")