Skip to content

Commit

Permalink
Added scheduled monuments dataset and made minor updates to the natur…
Browse files Browse the repository at this point in the history
…e reserves and sites of special scientific interest readme/metadata and scripts - no change to the data.
  • Loading branch information
itsozz committed Aug 16, 2024
1 parent c70e41b commit 29bd0a8
Show file tree
Hide file tree
Showing 7 changed files with 157 additions and 6 deletions.
2 changes: 1 addition & 1 deletion local_nature_reserves/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</tr>
<tr>
<td>Attribution</td>
<td>&copy; Natural England copyright. Contains Ordnance Survey data &copy; Crown copyright and database right [year].</td>
<td>&copy; Natural England copyright. Contains Ordnance Survey data &copy; Crown copyright and database right 2024.</td>
</tr>
<tr>
<td>Format</td>
Expand Down
3 changes: 1 addition & 2 deletions local_nature_reserves/pre-processing.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ df_lnr <- df_lnr %>%
site_area_square_metres = Shape__Area,
natural_england_gid = GID,
british_map_grid_reference = REFERENCE) %>%
# Calculate and store the coordinates of each locality's centroid as a "lat" and "lon" property
mutate(lon = map_dbl(geometry, ~st_centroid(.x)[[1]]),
mutate(lon = map_dbl(geometry, ~st_centroid(.x)[[1]]), # Calculate the coordinates of the area's centroid as a "lat" and "lon" property
lat = map_dbl(geometry, ~st_centroid(.x)[[2]]),
site_area_hectares = as.numeric(str_trim(format(site_area_hectares, nsmall = 2))),
site_area_square_metres = as.numeric(str_trim(format(site_area_square_metres, nsmall = 2)))) %>%
Expand Down
66 changes: 66 additions & 0 deletions scheduled_monuments/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<table>
<tr>
<td>Dataset name</td>
<td>Scheduled Monuments in Trafford</td>
</tr>
<tr>
<td>Dataset description</td>
<td>Historic buildings and archaeological sites of national importance are given legal protection by being placed on a ‘Schedule’ of monuments. Historic England identifies and advises on these monuments, which are placed on the Schedule by the Department for Culture, Media and Sport. Examples of Scheduled Monuments are Roman remains, burial mounds, castles, bridges, earthworks, the remains of deserted villages, and industrial sites. Scheduled Monuments can not include ecclesiastical or residential buildings (except for associated caretaker’s dwellings), and unlike Listed Buildings they are not assigned grades.</td>
</tr>
<tr>
<td>Source</td>
<td>Historic England</td>
</tr>
<tr>
<td>Publisher</td>
<td>Historic England</td>
</tr>
<tr>
<td>Publisher URL</td>
<td><a href="https://opendata-historicengland.hub.arcgis.com/maps/767f279327a24845bf47dfe5eae9862b/about">https://opendata-historicengland.hub.arcgis.com/maps/767f279327a24845bf47dfe5eae9862b/about</a></td>
</tr>
<tr>
<td>Geography</td>
<td>Local authority</td>
</tr>
<tr>
<td>Geographic coverage</td>
<td>Trafford</td>
</tr>
<tr>
<td>Temporal coverage</td>
<td>2024-08-16</td>
</tr>
<tr>
<td>Update frequency</td>
<td>Unknown</td>
</tr>
<tr>
<td>Licence</td>
<td><a href="http://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/">Open Government Licence</a></td>
</tr>
<tr>
<td>Attribution</td>
<td>&copy; Historic England 2024. Contains Ordnance Survey data &copy; Crown copyright and database right 2024.</td>
</tr>
<tr>
<td>Format</td>
<td>GeoJSON</td>
</tr>
<tr>
<td>Openness rating</td>
<td>&#9733&#9733&#9733&#9734&#9734&nbsp; Structured data in open format (e.g. CSV)</td>
</tr>
<tr>
<td>Last updated</td>
<td>2024-08-16</td>
</tr>
<tr>
<td>Notes</td>
<td></td>
</tr>
<tr>
<td>Lab visualisation</td>
<td>View data within the Lab's <a href="https://www.trafforddatalab.io/explore/#dataset=scheduled_monuments">Explore application</a>.</td>
</tr>
</table>
79 changes: 79 additions & 0 deletions scheduled_monuments/pre-processing.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Scheduled Monuments in Trafford
# Created 2024-08-16
# Data updated: 2024-08-16
# Data: https://opendata-historicengland.hub.arcgis.com/maps/767f279327a24845bf47dfe5eae9862b/about
# Metadata: https://historicengland.org.uk/listing/the-list/data-downloads
# Licence: Open Government Licence v3 (https://historicengland.org.uk/terms/website-terms-conditions/open-data-hub/)

# NOTES:
# These features are obtained from an ArcGIS API service, similar to that of the ONS Geography Portal.
# The default API call returns features for the whole county, therefore it's best to use some extra parameters, such as defining a rectangle (spatial envelope) around the LA, to reduce the amount of data being returned and speed up the process.


# Required packages ---------
library(tidyverse) ; library(sf)

# =========
# VERY IMPORTANT NOTE REGARDING SF PACKAGE AND COORDINATE WINDING ORDER 2023-12-21:
# The IETF standard for GeoJSON has made certain changes over the original non-IETF specification. The changes can be viewed here: https://datatracker.ietf.org/doc/html/rfc7946#appendix-B
# One key change is that polygon rings MUST follow the right-hand rule for orientation (counter-clockwise external rings, clockwise internal rings).
# This change has caused issues with certain libraries which have historically used the left-hand rule, i.e. clockwise for outer rings and counter-clockwise for interior rings.
# D3-Geo, Vega-Lite and versions of sf below 1.0.0 (default behaviour) use the GEOS library for performing flat-space calculations, known as R^2 (R-squared) which produce polygons wound to the left-hand rule.
# The sf package from version 1.0.0 onwards now uses the S2 library by default which performs S^2 (S-squared) spherical calculations and returns polygons wound according to the right-hand rule.
# At the time of writing, if we want our geography files to work in D3 and Vega-Lite, they must use the left-hand rule and so we need sf to use the GEOS library not S2.
# More information regarding this can be found at: https://r-spatial.github.io/sf/articles/sf7.html#switching-between-s2-and-geos
# =========
sf_vers <- package_version(packageVersion('sf')) # packageVersion returns a character string, package_version converts that into numeric version numbers (major.minor.patch) e.g. 1.0.0

# Only run the following if we are using sf version 1.0.0 or above
if (sf_vers$major >= 1) {
useS2 <- sf_use_s2() # store boolean to indicating if sf is currently using the s2 spherical geometry package for geographical coordinate operations
sf_use_s2(FALSE) # force sf to use R^2 flat space calculations using GEOS which returns polygons with left-hand windings
}


# API parameters specifying the spatial rectangular area containing Trafford
api_geommetry_envelope <- "&geometryType=esriGeometryEnvelope&geometry=%7B%22spatialReference%22%3A%7B%22latestWkid%22%3A3857%2C%22wkid%22%3A102100%7D%2C%22xmin%22%3A-278455.35481123265%2C%22ymin%22%3A7047642.057770884%2C%22xmax%22%3A-244823.0623658004%2C%22ymax%22%3A7073592.428873666%2C%22type%22%3A%22esriGeometryEnvelope%22%7D"


# Local authority district -------------------------
# Source: ONS Open Geography Portal
# URL: https://geoportal.statistics.gov.uk/datasets/ons::local-authority-districts-may-2023-boundaries-uk-bfc/about
# Licence: OGL v3.0
# NOTE: we need the LA boundary stored as an sf object for use in st_intersection() calculations for other boundaries/features
# we use the full resolution version as this ensures any features near the border are included/not included correctly
la <- st_read("https://services1.arcgis.com/ESMARspQHYMw9BZ9/arcgis/rest/services/Local_Authority_Districts_May_2023_UK_BFC_V2/FeatureServer/0/query?outFields=*&where=UPPER(lad23cd)%20like%20%27%25E08000009%25%27&f=geojson") %>%
select(area_code = LAD23CD, area_name = LAD23NM)


# Get the information for items within Trafford -------------------------
df_monuments <- st_read(paste0("https://services-eu1.arcgis.com/ZOdPfBS3aqqDYPUQ/arcgis/rest/services/National_Heritage_List_for_England_NHLE_v02_VIEW/FeatureServer/6/query?outFields=*&where=1%3D1&f=geojson", api_geommetry_envelope)) %>%
st_intersection(la)

# Process the dataset, renaming and creating required variables
df_monuments <- df_monuments %>%
rename(site_name = Name,
site_area_hectares = area_ha,
list_entry_number = ListEntry,
list_entry_url = hyperlink,
british_map_grid_reference = NGR) %>%
mutate(lon = map_dbl(geometry, ~st_centroid(.x)[[1]]), # Calculate the coordinates of the area's centroid as a "lat" and "lon" property
lat = map_dbl(geometry, ~st_centroid(.x)[[2]]),
site_area_hectares = as.numeric(str_trim(format(site_area_hectares, nsmall = 2))),
site_area_square_metres = site_area_hectares * 10000) %>%
select(site_name,
site_area_hectares,
site_area_square_metres,
list_entry,
list_url,
british_map_grid_reference,
lon,
lat)


# Create the Local Nature Reserves file for Trafford -------------------------
st_write(df_monuments, "trafford_scheduled_monuments.geojson")


# Ensure sf_use_s2() is reset to the state it was in before running the code above, i.e. whether to use the S2 library (for S^2 spherical coordinates) or GEOS (for R^2 flat space coordinates). Only if using v1 or above of the sf package
if (sf_vers$major >= 1) sf_use_s2(useS2)
8 changes: 8 additions & 0 deletions scheduled_monuments/trafford_scheduled_monuments.geojson
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"type": "FeatureCollection",
"name": "trafford_scheduled_monuments",
"crs": { "type": "name", "properties": { "name": "urn:ogc:def:crs:OGC:1.3:CRS84" } },
"features": [
{ "type": "Feature", "properties": { "site_name": "Watch Hill motte and bailey castle, 450m south of Streethead Farm", "site_area_hectares": 0.7828463, "site_area_square_metres": 7828.463, "list_entry_number": 1014377, "list_entry_url": "https://historicengland.org.uk/listing/the-list/list-entry/1014377", "british_map_grid_reference": "SJ 74784 85993", "lon": -2.3803079602367201, "lat": 53.370190155860683 }, "geometry": { "type": "Polygon", "coordinates": [ [ [ -2.37984783830283, 53.370427120498697 ], [ -2.37983234342683, 53.370427169835096 ], [ -2.37981731194005, 53.370426939061304 ], [ -2.37980181700674, 53.370426988394001 ], [ -2.37978632213072, 53.370427037724497 ], [ -2.37976329767477, 53.370427111022899 ], [ -2.3797327762777, 53.370427486814002 ], [ -2.37939873181289, 53.370415632936798 ], [ -2.37937570987744, 53.370414294951999 ], [ -2.37936066095387, 53.370412104624897 ], [ -2.37934560691112, 53.370409339044699 ], [ -2.379331492252, 53.370405734508303 ], [ -2.37931781836636, 53.370400996035301 ], [ -2.37930510398394, 53.370395984826601 ], [ -2.37929331134866, 53.370389847101997 ], [ -2.37928244801546, 53.3703834187707 ], [ -2.37927252393068, 53.370376142535598 ], [ -2.3792639951799, 53.370368592214398 ], [ -2.379256408134, 53.370360463597002 ], [ -2.3792506947541, 53.370351771756802 ], [ -2.37924592827742, 53.370343085855403 ], [ -2.37924255697245, 53.370334107901797 ], [ -2.37924059588173, 53.370324846832098 ], [ -2.379242772875, 53.3703060176178 ], [ -2.37924551328582, 53.370296453950502 ], [ -2.37925053082823, 53.370280995475099 ], [ -2.37925512233706, 53.370268333803701 ], [ -2.37925879710153, 53.370259054816401 ], [ -2.3792634061427, 53.370250051491603 ], [ -2.37926802772266, 53.3702407694594 ], [ -2.37927263676, 53.370231766134097 ], [ -2.37927819013432, 53.370222481173201 ], [ -2.37928374598608, 53.370213474837101 ], [ -2.37928930431539, 53.370204747125598 ], [ -2.37929580698069, 53.370195737778303 ], [ -2.37930229710286, 53.370187007137702 ], [ -2.37930927067286, 53.3701785625761 ], [ -2.37931624173721, 53.370169830371097 ], [ -2.3793236811488, 53.3701613753435 ], [ -2.37933158650702, 53.370152927817401 ], [ -2.37933949439997, 53.370144758949898 ], [ -2.37934788309973, 53.370136579534801 ], [ -2.3793567227253, 53.370128407703099 ], [ -2.37936557990579, 53.370120514447699 ], [ -2.37937490295225, 53.37011261971 ], [ -2.37938422847573, 53.370105003596599 ], [ -2.37939403496586, 53.3700973949706 ], [ -2.37940429475872, 53.370090054551298 ], [ -2.37941456964873, 53.370082723066702 ], [ -2.37942482943465, 53.370075382645503 ], [ -2.37943557272444, 53.370068328301997 ], [ -2.37944678436052, 53.370061551135002 ], [ -2.37945799599309, 53.3700547739668 ], [ -2.37946967349058, 53.370047995315502 ], [ -2.37948135352313, 53.370041495322198 ], [ -2.38015904811078, 53.369582497042899 ], [ -2.38017546585479, 53.3696185432294 ], [ -2.38021199209271, 53.369654525353901 ], [ -2.38026490834128, 53.369721735774 ], [ -2.38032610140121, 53.369815400450399 ], [ -2.38035886527459, 53.369850783258698 ], [ -2.3803641303747, 53.3698614360314 ], [ -2.38036939304795, 53.369871810178601 ], [ -2.38037558753689, 53.369882190303599 ], [ -2.38038177951907, 53.369892282819599 ], [ -2.38038892074559, 53.369902650975497 ], [ -2.38039652292536, 53.369912460326503 ], [ -2.38040459095304, 53.369922259242003 ], [ -2.38041313995202, 53.369932065572598 ], [ -2.38042167144721, 53.3699415933254 ], [ -2.38043114967859, 53.369951109074599 ], [ -2.38044109137455, 53.369960353695603 ], [ -2.38045151145245, 53.369969309139002 ], [ -2.38046239737945, 53.369978254112098 ], [ -2.38047326582548, 53.369986929456402 ], [ -2.38048509616768, 53.369995601765901 ], [ -2.38049690638072, 53.370003707820104 ], [ -2.38050918252381, 53.370011812421303 ], [ -2.38052193720967, 53.370019645811098 ], [ -2.3805351576079, 53.370027459746602 ], [ -2.38054885400384, 53.3700347238454 ], [ -2.38056253536084, 53.370041979006999 ], [ -2.38057714605106, 53.370048961518499 ], [ -2.38059130332969, 53.370055657858103 ], [ -2.38060638991884, 53.370062072598003 ], [ -2.38062147394351, 53.370068199693101 ], [ -2.38063702140965, 53.370074046640198 ], [ -2.38065304728075, 53.370079613425602 ], [ -2.38066905564661, 53.370084901631799 ], [ -2.38068507654789, 53.370089911128602 ], [ -2.38070156075231, 53.370094631493501 ], [ -2.38071849337691, 53.370099071791998 ], [ -2.38073543853649, 53.370103233415001 ], [ -2.38075239615014, 53.370107107344801 ], [ -2.38135985459561, 53.370228419650701 ], [ -2.38146469287428, 53.370254556110297 ], [ -2.38151722405508, 53.370278450832402 ], [ -2.3815934777632, 53.370308067320003 ], [ -2.38161005019536, 53.370322620913001 ], [ -2.38161764266524, 53.370331306672497 ], [ -2.3816243083276, 53.370340552662697 ], [ -2.38162908542123, 53.370350371012997 ], [ -2.38163293071601, 53.370360192309903 ], [ -2.38163489739032, 53.3703700196508 ], [ -2.38163545386667, 53.370380130136297 ], [ -2.38163461003693, 53.3703899574502 ], [ -2.38163234100998, 53.370400076974697 ], [ -2.38162867181308, 53.370409922345097 ], [ -2.3816235998694, 53.370419205884097 ], [ -2.38161710015044, 53.370428494024502 ], [ -2.38160920020138, 53.370437507976099 ], [ -2.38159988006836, 53.370445690501903 ], [ -2.38158962555399, 53.370453588398803 ], [ -2.3815779382488, 53.370460924593203 ], [ -2.38156531408997, 53.370467706482401 ], [ -2.38155175069786, 53.3704736554402 ], [ -2.38153771372727, 53.370478751975597 ], [ -2.38152272494048, 53.370483294252601 ], [ -2.38150678176288, 53.370486994627903 ], [ -2.381490846121, 53.370489859043303 ], [ -2.38147442196332, 53.370491880101 ], [ -2.38145752179399, 53.370492770075501 ], [ -2.38125275134552, 53.370493424668801 ], [ -2.38122975198663, 53.370494621754098 ], [ -2.38121426209677, 53.370495237537902 ], [ -2.38119875716268, 53.370495844384003 ], [ -2.38118326727189, 53.3704964601638 ], [ -2.38116777486576, 53.370496788332701 ], [ -2.38115180150775, 53.370497118002 ], [ -2.38113631161585, 53.370497733775601 ], [ -2.3811208167169, 53.370497783278999 ], [ -2.38110532425242, 53.37049811144 ], [ -2.38108981682396, 53.370498439612398 ], [ -2.38107432186736, 53.370498489109899 ], [ -2.38105882696802, 53.370498538605297 ], [ -2.38104333201133, 53.370498588098698 ], [ -2.38102782209113, 53.370498637638001 ], [ -2.38101232713435, 53.370498687127501 ], [ -2.38099636381343, 53.370498459477602 ], [ -2.38098085140219, 53.370498230351302 ], [ -2.38096535395481, 53.370498001209597 ], [ -2.38094985648433, 53.370497763047801 ], [ -2.38093435903725, 53.370497533901997 ], [ -2.38091884413625, 53.370497026142502 ], [ -2.38090334411877, 53.370496509349799 ], [ -2.38088784415896, 53.370495992554801 ], [ -2.38087232920172, 53.370495484789501 ], [ -2.38085682932291, 53.370494976974001 ], [ -2.38084132681671, 53.370494181513898 ], [ -2.3808258243687, 53.370493386085798 ], [ -2.38081030684286, 53.3704925906695 ], [ -2.38079480447622, 53.370491804220897 ], [ -2.38077930197226, 53.370491008752602 ], [ -2.38076379703682, 53.370489934657101 ], [ -2.38074827951362, 53.3704891392671 ], [ -2.38073277457961, 53.370488065167599 ], [ -2.38071726709968, 53.370486712406802 ], [ -2.38070222804038, 53.370485636816497 ], [ -2.38068672310873, 53.370484562710999 ], [ -2.38067120061101, 53.370483210026499 ], [ -2.38065569311178, 53.370481848274103 ], [ -2.38064065156711, 53.370480494051002 ], [ -2.3806251440927, 53.370479141278402 ], [ -2.38060963410801, 53.3704775008949 ], [ -2.38059459256624, 53.3704761466661 ], [ -2.38057908252644, 53.370474506278903 ], [ -2.38056355760458, 53.3704728749209 ], [ -2.38054851100912, 53.370470954383997 ], [ -2.38053300105306, 53.370469322974301 ], [ -2.38051795446049, 53.370467402467902 ], [ -2.38050290786889, 53.370465481925301 ], [ -2.38048739540605, 53.370463562901001 ], [ -2.38047235387258, 53.370462208622598 ], [ -2.38045730985265, 53.370460575717203 ], [ -2.38044226575369, 53.370458933826399 ], [ -2.38042722422351, 53.370457579576602 ], [ -2.38041218020686, 53.370455946665601 ], [ -2.38039667266806, 53.370454584880001 ], [ -2.38038163114077, 53.370453230624499 ], [ -2.38036658961412, 53.370451876332901 ], [ -2.38035153298776, 53.370450513138103 ], [ -2.38033602559029, 53.370449160328 ], [ -2.38032098655325, 53.370448084690103 ], [ -2.38030594503054, 53.370446730425101 ], [ -2.38029090599506, 53.370445654783403 ], [ -2.38027540103034, 53.370444580624998 ], [ -2.38026035950994, 53.370443226320099 ], [ -2.38024485460417, 53.3704421521577 ], [ -2.38022981805798, 53.3704413551676 ], [ -2.38021477902621, 53.370440279516401 ], [ -2.38019927406525, 53.370439205348198 ], [ -2.38018423752058, 53.370438408318201 ], [ -2.3801687175976, 53.370437334193802 ], [ -2.38015368105442, 53.370436537194301 ], [ -2.38013817866173, 53.370435750626697 ], [ -2.38012314211965, 53.370434953623402 ], [ -2.38010763970528, 53.3704341580682 ], [ -2.38009260572945, 53.370433648669596 ], [ -2.38007708823825, 53.370432853192902 ], [ -2.38006205426325, 53.370432343790398 ], [ -2.38004655185086, 53.370431548227401 ], [ -2.3800315177965, 53.370431029837597 ], [ -2.38001601789275, 53.370430521913697 ], [ -2.38000098383909, 53.370430003519999 ], [ -2.37998548647801, 53.370429774251299 ], [ -2.37997045250508, 53.370429264837298 ], [ -2.37995495252252, 53.370428747921999 ], [ -2.37993944014103, 53.370428518660802 ], [ -2.37992440865331, 53.370428287900403 ], [ -2.37990891115545, 53.3704280496042 ], [ -2.37989387966803, 53.3704278188399 ], [ -2.37987838230792, 53.370427589523104 ], [ -2.37986286979014, 53.370427351303 ], [ -2.37984783830283, 53.370427120498697 ] ] ] } }
]
}
2 changes: 1 addition & 1 deletion sites_of_special_scientific_interest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
</tr>
<tr>
<td>Attribution</td>
<td>&copy; Natural England copyright. Contains Ordnance Survey data &copy; Crown copyright and database right [year].</td>
<td>&copy; Natural England copyright. Contains Ordnance Survey data &copy; Crown copyright and database right 2024.</td>
</tr>
<tr>
<td>Format</td>
Expand Down
3 changes: 1 addition & 2 deletions sites_of_special_scientific_interest/pre-processing.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ df_sssi <- df_sssi %>%
site_area_square_metres = Shape__Area,
natural_england_site_id = ENSISID,
british_map_grid_reference = REFERENCE) %>%
# Calculate and store the coordinates of each locality's centroid as a "lat" and "lon" property
mutate(lon = map_dbl(geometry, ~st_centroid(.x)[[1]]),
mutate(lon = map_dbl(geometry, ~st_centroid(.x)[[1]]), # Calculate the coordinates of the area's centroid as a "lat" and "lon" property
lat = map_dbl(geometry, ~st_centroid(.x)[[2]]),
site_area_hectares = as.numeric(str_trim(format(site_area_hectares, nsmall = 2))),
site_area_square_metres = as.numeric(str_trim(format(site_area_square_metres, nsmall = 2)))) %>%
Expand Down

0 comments on commit 29bd0a8

Please sign in to comment.