DMgtAsia · Session-III
sf implements Simple Features, the ISO standard for representing geometry.sf object is a data frame with a special geometry column.MULTIPOLYGON for a state made of many parts).Press Run. We make points for four cities, then attach geometry.
Note the geometry column and the printed CRS header.
viewof q1 = Inputs.radio(
["st_read()", "st_as_sf()", "st_transform()", "st_crs()"],
{ label: "Which function converts a data frame with lon/lat columns into an sf object?" }
);
html`${q1 == null ? "" : q1 === "st_as_sf()" ? "<strong>Correct.</strong> st_as_sf() turns a data frame with coordinate columns into an sf object." : "<em>Not quite.</em> Which function turns lon/lat columns into geometry?"}`The numbers change from degrees to metres after st_transform().
viewof q2 = Inputs.radio(
["Geodetic, in degrees", "Projected, in metres", "Always a UTM zone", "An equal-area projection"],
{ label: "EPSG:4326 (WGS 84) is..." }
);
html`${q2 == null ? "" : q2 === "Geodetic, in degrees" ? "<strong>Correct.</strong> EPSG:4326 (WGS 84) is geodetic: longitude/latitude in degrees." : "<em>Try again.</em> 4326 is the familiar lon/lat system."}`geom_sf() reads the geometry column directly. The same layer draws points, lines, or polygons.
In RStudio you read a shapefile or GeoJSON from disk:
You do this in Exercise 1. We keep file reading in RStudio because the data files are large for a browser session.
sf core, st_as_sf, st_crs, st_transform, geom_sf.exactextractr, raster) in Exercise 3.tidygeocoder) in Exercise 4.spdep, rgeoda, Moran’s I, LISA) in Session-IV.These packages are not yet built for WebAssembly, so they stay in the desktop exercises.
case_when name harmonisation.Each is an R script you run in RStudio.
sf is tidy data with a geometry column.st_as_sf builds geometry; st_crs reads it; st_transform reprojects.geom_sf maps it.
DMgtAsia · Spatial Epidemiology