Skip to content

Commit

Permalink
Built site for gh-pages
Browse files Browse the repository at this point in the history
  • Loading branch information
Quarto GHA Workflow Runner committed Jun 28, 2024
1 parent 44adb15 commit aa3c2d6
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .nojekyll
Original file line number Diff line number Diff line change
@@ -1 +1 @@
af19fce9
ba69cc04
201 changes: 189 additions & 12 deletions mod_spatial.html

Large diffs are not rendered by default.

Binary file added mod_spatial_files/figure-html/plot-raster-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added mod_spatial_files/figure-html/plot-vector-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 3 additions & 3 deletions search.json
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@
"href": "mod_spatial.html#learning-objectives",
"title": "Working with Spatial Data",
"section": "Learning Objectives",
"text": "Learning Objectives\nAfter completing this topic you will be able to:\n\nDefine the difference between the two major types of spatial data\nManipulate spatial data with R\nIntegrate spatial data with tabular data",
"text": "Learning Objectives\nAfter completing this topic you will be able to:\n\nDefine the difference between the two major types of spatial data\nManipulate spatial data with R\nCreate maps using spatial data\nIntegrate spatial data with tabular data",
"crumbs": [
"Bonus Modules",
"Spatial Data"
Expand All @@ -424,7 +424,7 @@
"href": "mod_spatial.html#types-of-spatial-data",
"title": "Working with Spatial Data",
"section": "Types of Spatial Data",
"text": "Types of Spatial Data\nThere are two main types of spatial data: vector and raster. You may have cause to work either or both so we’ll describe both (and the packages they require) in the tabs below.\n\nVector DataRaster Data\n\n\nData stored as polygons / shapes\n\n# Load needed library\nlibrary(sf)\n\n\n\nData stored as pixels\n\n# Load needed library\nlibrary(terra)",
"text": "Types of Spatial Data\nThere are two main types of spatial data: vector and raster. Both types (and the packages they require) are described in the tabs below.\n\nVector DataRaster Data\n\n\nVector data are stored as polygons. Essentially vector data are a set of points and–sometimes–the lines between them that define the edges of a shape. They may store additional data that is retained in a semi-tabular format that relates to the polygon(s) but isn’t directly stored in them.\nCommon vector data types include shape files or GeoJSONs.\n\n# Load needed library\nlibrary(sf)\n\n# Read in shapefile\n1nc_poly <- sf::st_read(dsn = file.path(\"data\", \"nc_borders.shp\"))\n\n\n1\n\nNote that even though we’re only specifying the “.shp” file in this function you must also have the associated files in that same folder. In this case that includes a “.dbf”, “.prj”, and “.shx”, though in other contexts you may have others.\n\n\n\n\nOnce you have read in the shapefile, you can check its structure as you would any other data object. Note that the object has both the ‘data.frame’ class and the ‘sf’ (“simple features”) class. In this case, the shapefile relates to counties in North Carolina and some associated demographic data in those counties.\n\n# Check structure\nstr(nc_poly)\n\nClasses 'sf' and 'data.frame': 100 obs. of 15 variables:\n $ AREA : num 0.114 0.061 0.143 0.07 0.153 0.097 0.062 0.091 0.118 0.124 ...\n $ PERIMETER: num 1.44 1.23 1.63 2.97 2.21 ...\n $ CNTY_ : num 1825 1827 1828 1831 1832 ...\n $ CNTY_ID : num 1825 1827 1828 1831 1832 ...\n $ NAME : chr \"Ashe\" \"Alleghany\" \"Surry\" \"Currituck\" ...\n $ FIPS : chr \"37009\" \"37005\" \"37171\" \"37053\" ...\n $ FIPSNO : num 37009 37005 37171 37053 37131 ...\n $ CRESS_ID : int 5 3 86 27 66 46 15 37 93 85 ...\n $ BIR74 : num 1091 487 3188 508 1421 ...\n $ SID74 : num 1 0 5 1 9 7 0 0 4 1 ...\n $ NWBIR74 : num 10 10 208 123 1066 ...\n $ BIR79 : num 1364 542 3616 830 1606 ...\n $ SID79 : num 0 3 6 2 3 5 2 2 2 5 ...\n $ NWBIR79 : num 19 12 260 145 1197 ...\n $ geometry :sfc_MULTIPOLYGON of length 100; first list element: List of 1\n ..$ :List of 1\n .. ..$ : num [1:27, 1:2] -81.5 -81.5 -81.6 -81.6 -81.7 ...\n ..- attr(*, \"class\")= chr [1:3] \"XY\" \"MULTIPOLYGON\" \"sfg\"\n - attr(*, \"sf_column\")= chr \"geometry\"\n - attr(*, \"agr\")= Factor w/ 3 levels \"constant\",\"aggregate\",..: NA NA NA NA NA NA NA NA NA NA ...\n ..- attr(*, \"names\")= chr [1:14] \"AREA\" \"PERIMETER\" \"CNTY_\" \"CNTY_ID\" ...\n\n\nIf desired, we could make a simple R base plot-style map. In this case we’ll do it based on just the county areas so that the polygons are filled with a color corresponding to how large the county is.\n\n# Make a graph\nplot(nc_poly[\"AREA\"], axes = T)\n\n\n\n\n\n\n\n\n\n\nRaster data are stored as values in pixels. The resolution (i.e., size of the pixels) may differ among rasters but in all cases the data are stored at a per-pixel level.\nCommon raster data types include GeoTIFFs (.tif) and NetCDF (.nc) files.\n\n# Load needed library\nlibrary(terra)\n\n# Read in raster\nnc_pixel <- terra::rast(x = file.path(\"data\", \"nc_elevation.tif\"))\n\nOnce you’ve read in the raster file you can check it’s structure as you would any other object but the resulting output is much less informative than for other object classes.\n\n# Check structure\nstr(nc_pixel)\n\nS4 class 'SpatRaster' [package \"terra\"]\n\n\nRegardless, now that we have the raster loaded we can make a simple graph to check out what sort of data is stored in it. In this case, each pixel is 3 arcseconds on each side (~0.0002° latitude/longitude) and contains the elevation (in meters) of that pixel.\n\n# Make a graph\nterra::plot(nc_pixel)",
"crumbs": [
"Bonus Modules",
"Spatial Data"
Expand All @@ -435,7 +435,7 @@
"href": "mod_spatial.html#coordinate-reference-systems",
"title": "Working with Spatial Data",
"section": "Coordinate Reference Systems",
"text": "Coordinate Reference Systems\nA fundamental problem in spatial data is how to project data collected on a nearly spherical planet onto a two-dimensional plane. This has been solved–or at least clarified–by the use of Coordinate Reference Systems (a.k.a. “CRS”). All spatial data have a CRS that is explicitly identified in the data and/or the metadata because the data are not interpretable without knowing which CRS is used.\nThe CRS defines the following information:\n\nDatum – model for shape of the Earth including the starting coordinate pair and angular units that together define any particular point on the planet\n\nNote that there can be global datums that work for any region of the world and local datums that only work for a particular area\n\nProjection – math for the transformation to get from a round planet to a flat map\nAdditional parameters – any other information necessary to support the projection\n\nE.g., the coordinates at the center of the map\n\n\nSome people use the analogy of peeling a citrus fruit and flattening the peel to describe the components of a CRS. The datum is the choice between a lemon or a grapefruit (i.e., the shape of the not-quite-spherical object) while the projection is the instructions for taking the complete peel and flattening it.\nYou can check and transform the CRS in any scripted language that allows the loading of spatial data though the specifics do differ between the two types of spatial data we introduced earlier.\n\nVector CRSRaster CRS\n\n\nsf::st_crs\nsf::st_transform\n\n\nterra::crs\nterra::project",
"text": "Coordinate Reference Systems\nA fundamental problem in spatial data is how to project data collected on a nearly spherical planet onto a two-dimensional plane. This has been solved–or at least clarified–by the use of Coordinate Reference Systems (a.k.a. “CRS”). All spatial data have a CRS that is explicitly identified in the data and/or the metadata because the data are not interpretable without knowing which CRS is used.\nThe CRS defines the following information:\n\nDatum – model for shape of the Earth including the starting coordinate pair and angular units that together define any particular point on the planet\n\nNote that there can be global datums that work for any region of the world and local datums that only work for a particular area\n\nProjection – math for the transformation to get from a round planet to a flat map\nAdditional parameters – any other information necessary to support the projection\n\nE.g., the coordinates at the center of the map\n\n\nSome people use the analogy of peeling a citrus fruit and flattening the peel to describe the components of a CRS. The datum is the choice between a lemon or a grapefruit (i.e., the shape of the not-quite-spherical object) while the projection is the instructions for taking the complete peel and flattening it.\nYou can check and transform the CRS in any scripted language that allows the loading of spatial data though the specifics do differ between the types of spatial data we introduced earlier.\n\nVector CRSRaster CRS\n\n\nFor vector data we can check the CRS with other functions from the sf library. It can be a little difficult to parse all of the information that returns but essentially it is most important that the CRS match that of any other spatial data with which we are working.\n\n# Check CRS\nsf::st_crs(x = nc_poly)\n\nCoordinate Reference System:\n User input: WGS 84 \n wkt:\nGEOGCRS[\"WGS 84\",\n DATUM[\"World Geodetic System 1984\",\n ELLIPSOID[\"WGS 84\",6378137,298.257223563,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n CS[ellipsoidal,2],\n AXIS[\"latitude\",north,\n ORDER[1],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n AXIS[\"longitude\",east,\n ORDER[2],\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n ID[\"EPSG\",4326]]\n\n\nOnce you know the CRS, you can transform the data to another CRS if desired. This is a relatively fast operation for vector data because we’re transforming geometric data rather than potentially millions of pixels.\n\n# Transform CRS\n1nc_poly_nad83 <- sf::st_transform(x = nc_poly, crs = 3083)\n\n# Re-check CRS\nsf::st_crs(nc_poly_nad83)\n\n\n1\n\nIn order to transform to a new CRS you’ll need to identify the four-digit EPSG code for the desired CRS.\n\n\n\n\nCoordinate Reference System:\n User input: EPSG:3083 \n wkt:\nPROJCRS[\"NAD83 / Texas Centric Albers Equal Area\",\n BASEGEOGCRS[\"NAD83\",\n DATUM[\"North American Datum 1983\",\n ELLIPSOID[\"GRS 1980\",6378137,298.257222101,\n LENGTHUNIT[\"metre\",1]]],\n PRIMEM[\"Greenwich\",0,\n ANGLEUNIT[\"degree\",0.0174532925199433]],\n ID[\"EPSG\",4269]],\n CONVERSION[\"Texas Centric Albers Equal Area\",\n METHOD[\"Albers Equal Area\",\n ID[\"EPSG\",9822]],\n PARAMETER[\"Latitude of false origin\",18,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8821]],\n PARAMETER[\"Longitude of false origin\",-100,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8822]],\n PARAMETER[\"Latitude of 1st standard parallel\",27.5,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8823]],\n PARAMETER[\"Latitude of 2nd standard parallel\",35,\n ANGLEUNIT[\"degree\",0.0174532925199433],\n ID[\"EPSG\",8824]],\n PARAMETER[\"Easting at false origin\",1500000,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8826]],\n PARAMETER[\"Northing at false origin\",6000000,\n LENGTHUNIT[\"metre\",1],\n ID[\"EPSG\",8827]]],\n CS[Cartesian,2],\n AXIS[\"easting (X)\",east,\n ORDER[1],\n LENGTHUNIT[\"metre\",1]],\n AXIS[\"northing (Y)\",north,\n ORDER[2],\n LENGTHUNIT[\"metre\",1]],\n USAGE[\n SCOPE[\"State-wide spatial data presentation requiring true area measurements.\"],\n AREA[\"United States (USA) - Texas.\"],\n BBOX[25.83,-106.66,36.5,-93.5]],\n ID[\"EPSG\",3083]]\n\n\n\n\nFor raster data we can check the CRS with other functions from the terra library. It can be a little difficult to parse all of the information that returns but essentially it is most important that the CRS match that of any other spatial data with which we are working.\n\n# Check CRS\nterra::crs(nc_pixel)\n\n[1] \"GEOGCRS[\\\"WGS 84\\\",\\n ENSEMBLE[\\\"World Geodetic System 1984 ensemble\\\",\\n MEMBER[\\\"World Geodetic System 1984 (Transit)\\\"],\\n MEMBER[\\\"World Geodetic System 1984 (G730)\\\"],\\n MEMBER[\\\"World Geodetic System 1984 (G873)\\\"],\\n MEMBER[\\\"World Geodetic System 1984 (G1150)\\\"],\\n MEMBER[\\\"World Geodetic System 1984 (G1674)\\\"],\\n MEMBER[\\\"World Geodetic System 1984 (G1762)\\\"],\\n MEMBER[\\\"World Geodetic System 1984 (G2139)\\\"],\\n ELLIPSOID[\\\"WGS 84\\\",6378137,298.257223563,\\n LENGTHUNIT[\\\"metre\\\",1]],\\n ENSEMBLEACCURACY[2.0]],\\n PRIMEM[\\\"Greenwich\\\",0,\\n ANGLEUNIT[\\\"degree\\\",0.0174532925199433]],\\n CS[ellipsoidal,2],\\n AXIS[\\\"geodetic latitude (Lat)\\\",north,\\n ORDER[1],\\n ANGLEUNIT[\\\"degree\\\",0.0174532925199433]],\\n AXIS[\\\"geodetic longitude (Lon)\\\",east,\\n ORDER[2],\\n ANGLEUNIT[\\\"degree\\\",0.0174532925199433]],\\n USAGE[\\n SCOPE[\\\"Horizontal component of 3D system.\\\"],\\n AREA[\\\"World.\\\"],\\n BBOX[-90,-180,90,180]],\\n ID[\\\"EPSG\\\",4326]]\"\n\n\nAs with vector data, if desired you can transform the data to another CRS. However, unlike vector data, transforming the CRS of raster data is very computationally intense. If at all possible you should avoid re-projecting rasters. If you must re-project, consider doing so in an environment with greater computing power than a typical laptop. Also, you should export a new raster in your preferred CRS after transforming so that you reduce the likelihood that you need to re-project again later in the lifecylce of your project.\nIn the interests of making this website reasonably quick to re-build, the following code chunk is not actually evaluated but is the correct syntax for this operation.\n\n# Transform CRS\nnc_pixel_nad83 <- terra::project(x = nc_pixel, y = \"epsg:3083\")\n\n# Re-check CRS\nterra::crs(nc_pixel_nad83)",
"crumbs": [
"Bonus Modules",
"Spatial Data"
Expand Down
52 changes: 26 additions & 26 deletions sitemap.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,106 +2,106 @@
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>https://lter.github.io/ssecr/mod_wrangle.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/mod_project-mgmt.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/mod_credit.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/mod_findings.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/mod_reports.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/policy_attendance.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/index.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/mod_spatial.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/CONTRIBUTING.html</loc>
<lastmod>2024-06-28T19:11:55.002Z</lastmod>
<lastmod>2024-06-28T19:52:25.286Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/mod_reproducibility.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/mod_facilitation.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/mod_version-control.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/mod_stats.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/proj_milestones.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/mod_thinking.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/policy_pronouns.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/mod_data-viz.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/instructors.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/policy_conduct.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/mod_data-disc.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/mod_template.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/mod_interactivity.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/policy_ai.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/policy_usability.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/mod_team-sci.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
<url>
<loc>https://lter.github.io/ssecr/mod_next-steps.html</loc>
<lastmod>2024-06-28T19:11:55.042Z</lastmod>
<lastmod>2024-06-28T19:52:25.326Z</lastmod>
</url>
</urlset>

0 comments on commit aa3c2d6

Please sign in to comment.