The default plot shows only the mesh. If show_intersection = TRUE
, the part
of the mesh that has 2 intersecting regions or more is contrasted to the rest.
# S3 method for polymer
plot(x, ..., show_intersection = FALSE)
polymer
arguments to polypath
logical, plot the intersection region contrasted to the pool (default FALSE
)
the input, invisibly
plot(polymer(A, B, C))
library(sf)
example(st_read)
#>
#> st_red> nc = st_read(system.file("shape/nc.shp", package="sf"))
#> Reading layer `nc' from data source
#> `/home/runner/work/_temp/Library/sf/shape/nc.shp' using driver `ESRI Shapefile'
#> Simple feature collection with 100 features and 14 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
#> Geodetic CRS: NAD27
#>
#> st_red> summary(nc) # note that AREA was computed using Euclidian area on lon/lat degrees
#> AREA PERIMETER CNTY_ CNTY_ID
#> Min. :0.0420 Min. :0.999 Min. :1825 Min. :1825
#> 1st Qu.:0.0910 1st Qu.:1.324 1st Qu.:1902 1st Qu.:1902
#> Median :0.1205 Median :1.609 Median :1982 Median :1982
#> Mean :0.1263 Mean :1.673 Mean :1986 Mean :1986
#> 3rd Qu.:0.1542 3rd Qu.:1.859 3rd Qu.:2067 3rd Qu.:2067
#> Max. :0.2410 Max. :3.640 Max. :2241 Max. :2241
#> NAME FIPS FIPSNO CRESS_ID
#> Length:100 Length:100 Min. :37001 Min. : 1.00
#> Class :character Class :character 1st Qu.:37050 1st Qu.: 25.75
#> Mode :character Mode :character Median :37100 Median : 50.50
#> Mean :37100 Mean : 50.50
#> 3rd Qu.:37150 3rd Qu.: 75.25
#> Max. :37199 Max. :100.00
#> BIR74 SID74 NWBIR74 BIR79
#> Min. : 248 Min. : 0.00 Min. : 1.0 Min. : 319
#> 1st Qu.: 1077 1st Qu.: 2.00 1st Qu.: 190.0 1st Qu.: 1336
#> Median : 2180 Median : 4.00 Median : 697.5 Median : 2636
#> Mean : 3300 Mean : 6.67 Mean :1050.8 Mean : 4224
#> 3rd Qu.: 3936 3rd Qu.: 8.25 3rd Qu.:1168.5 3rd Qu.: 4889
#> Max. :21588 Max. :44.00 Max. :8027.0 Max. :30757
#> SID79 NWBIR79 geometry
#> Min. : 0.00 Min. : 3.0 MULTIPOLYGON :100
#> 1st Qu.: 2.00 1st Qu.: 250.5 epsg:4267 : 0
#> Median : 5.00 Median : 874.5 +proj=long...: 0
#> Mean : 8.36 Mean : 1352.8
#> 3rd Qu.:10.25 3rd Qu.: 1406.8
#> Max. :57.00 Max. :11631.0
#>
#> st_red> ## only three fields by select clause
#> st_red> ## only two features by where clause
#> st_red> nc_sql = st_read(system.file("shape/nc.shp", package="sf"),
#> st_red+ query = "SELECT NAME, SID74, FIPS FROM \"nc\" WHERE BIR74 > 20000")
#> Reading query `SELECT NAME, SID74, FIPS FROM "nc" WHERE BIR74 > 20000'
#> from data source `/home/runner/work/_temp/Library/sf/shape/nc.shp' using driver `ESRI Shapefile'
#> Simple feature collection with 2 features and 3 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: -81.06555 ymin: 34.82742 xmax: -78.49929 ymax: 35.50912
#> Geodetic CRS: NAD27
#>
#> st_red> ## Not run:
#> st_red> ##D library(sp)
#> st_red> ##D example(meuse, ask = FALSE, echo = FALSE)
#> st_red> ##D try(st_write(st_as_sf(meuse), "PG:dbname=postgis", "meuse",
#> st_red> ##D layer_options = "OVERWRITE=true"))
#> st_red> ##D try(st_meuse <- st_read("PG:dbname=postgis", "meuse"))
#> st_red> ##D if (exists("st_meuse"))
#> st_red> ##D summary(st_meuse)
#> st_red> ## End(Not run)
#> st_red>
#> st_red> ## Not run:
#> st_red> ##D ## note that we need special escaping of layer within single quotes (nc.gpkg)
#> st_red> ##D ## and that geom needs to be included in the select, otherwise we don't detect it
#> st_red> ##D layer <- st_layers(system.file("gpkg/nc.gpkg", package = "sf"))$name[1]
#> st_red> ##D nc_gpkg_sql = st_read(system.file("gpkg/nc.gpkg", package = "sf"),
#> st_red> ##D query = sprintf("SELECT NAME, SID74, FIPS, geom FROM \"%s\" WHERE BIR74 > 20000", layer))
#> st_red> ## End(Not run)
#> st_red> # spatial filter, as wkt:
#> st_red> wkt = st_as_text(st_geometry(nc[1,]))
#>
#> st_red> # filter by (bbox overlaps of) first feature geometry:
#> st_red> st_read(system.file("gpkg/nc.gpkg", package="sf"), wkt_filter = wkt)
#> Reading layer `nc.gpkg' from data source
#> `/home/runner/work/_temp/Library/sf/gpkg/nc.gpkg' using driver `GPKG'
#> Simple feature collection with 4 features and 14 fields
#> Geometry type: MULTIPOLYGON
#> Dimension: XY
#> Bounding box: xmin: -81.91116 ymin: 35.98933 xmax: -80.87086 ymax: 36.58965
#> Geodetic CRS: NAD27
#>
#> st_red> # read geojson from string:
#> st_red> geojson_txt <- paste("{\"type\":\"MultiPoint\",\"coordinates\":",
#> st_red+ "[[3.2,4],[3,4.6],[3.8,4.4],[3.5,3.8],[3.4,3.6],[3.9,4.5]]}")
#>
#> st_red> x = st_read(geojson_txt)
#> Reading layer `OGRGeoJSON' from data source
#> `{"type":"MultiPoint","coordinates": [[3.2,4],[3,4.6],[3.8,4.4],[3.5,3.8],[3.4,3.6],[3.9,4.5]]}'
#> using driver `GeoJSON'
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOINT
#> Dimension: XY
#> Bounding box: xmin: 3 ymin: 3.6 xmax: 3.9 ymax: 4.6
#> Geodetic CRS: WGS 84
#>
#> st_red> x
#> Simple feature collection with 1 feature and 0 fields
#> Geometry type: MULTIPOINT
#> Dimension: XY
#> Bounding box: xmin: 3 ymin: 3.6 xmax: 3.9 ymax: 4.6
#> Geodetic CRS: WGS 84
#> geometry
#> 1 MULTIPOINT ((3.2 4), (3 4.6...
#>
#> st_red> ## Not run:
#> st_red> ##D library(RPostgreSQL)
#> st_red> ##D try(conn <- dbConnect(PostgreSQL(), dbname = "postgis"))
#> st_red> ##D if (exists("conn") && !inherits(conn, "try-error")) {
#> st_red> ##D x = st_read(conn, "meuse", query = "select * from meuse limit 3;")
#> st_red> ##D x = st_read(conn, table = "public.meuse")
#> st_red> ##D print(st_crs(x)) # SRID resolved by the database, not by GDAL!
#> st_red> ##D dbDisconnect(conn)
#> st_red> ##D }
#> st_red> ## End(Not run)
#> st_red>
#> st_red>
#> st_red>
nc <- nc[1:5, ]
x <- polymer(nc, st_jitter(nc, amount = 0.1))
plot(x)