{"id":20517647,"url":"https://github.com/francisbarton/mapirosa","last_synced_at":"2026-02-14T02:34:20.144Z","repository":{"id":47460216,"uuid":"516144395","full_name":"francisbarton/mapirosa","owner":"francisbarton","description":"Access Ordnance Survey APIs From R","archived":false,"fork":false,"pushed_at":"2024-09-09T20:12:36.000Z","size":3270,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-06T06:11:55.901Z","etag":null,"topics":["27700","3857","api-client","basemaps","bng","mapping-tools","maps","ordnance-survey","ordnancesurvey","rstats-package"],"latest_commit_sha":null,"homepage":"","language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/francisbarton.png","metadata":{"files":{"readme":"README.md","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-20T21:51:32.000Z","updated_at":"2024-09-09T20:12:39.000Z","dependencies_parsed_at":"2024-09-09T23:51:08.897Z","dependency_job_id":"b36c4ca5-4599-47b2-883a-64ebff8c3ea2","html_url":"https://github.com/francisbarton/mapirosa","commit_stats":{"total_commits":22,"total_committers":2,"mean_commits":11.0,"dds":"0.31818181818181823","last_synced_commit":"301d85062f3f2ad1141473c13e5988892eecbe67"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francisbarton%2Fmapirosa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francisbarton%2Fmapirosa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francisbarton%2Fmapirosa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/francisbarton%2Fmapirosa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/francisbarton","download_url":"https://codeload.github.com/francisbarton/mapirosa/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248804783,"owners_count":21164131,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["27700","3857","api-client","basemaps","bng","mapping-tools","maps","ordnance-survey","ordnancesurvey","rstats-package"],"created_at":"2024-11-15T21:36:33.800Z","updated_at":"2026-02-14T02:34:15.099Z","avatar_url":"https://github.com/francisbarton.png","language":"R","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n# mapirosa\n\n\u003c!-- badges: start --\u003e\n\u003c!-- badges: end --\u003e\n\n## Access OS OpenData APIs From R\n\nA package to enable accessing basemap tiles from the [OS Maps\nAPI](https://osdatahub.os.uk/docs/wmts/overview), initially. Access to\nother OS (Ordnance Survey) Data Hub APIs may follow. The primary\nmotivation for this project was to find a map tile service that supplies\ntiles in the British National Grid (27700) CRS, unlike the usual web\nmapping standard CRS of 3857. The name of the package is an intentional\ncorruption of the Spanish word mariposa 🦋.\n\n\u003c!-- http://www.rocketandco.co.uk/Site/Butterfly_Map_Art_files/final1.jpg --\u003e\n\n![two butterfly shapes cut out from paper maps](buttermap.jpg)\n\n## Installation\n\n``` r\nremotes::install_github(\"francisbarton/mapirosa\")\n```\n\nTo use the package you will need to have an API key from the Ordnance\nSurvey website. Save this as an environment variable called\n`OS_DATA_KEY`\n\nThe easiest way to do this is to add a line to your `.Renviron` file\nlike:\n\n`OS_DATA_KEY = abcd1234`\n\n## Create basemaps using raster data (PNGs)\n\n### Examples:\n\n``` r\n\nlibrary(mapirosa)\n\nif (requireNamespace(\"osmdata\")) {\n  oxford1 \u003c- create_bbox(\"Oxford\", 27700)\n} else {\n  oxford1 \u003c- c(\n    xmin = 448100.3,\n    ymin = 201646.6,\n    xmax = 457014.2,\n    ymax = 211088.8\n  )\n}\n#\u003e Loading required namespace: osmdata\n\noxford_basemap1 \u003c- build_basemap(\n  bbox = oxford1,\n  zoom = 5,\n  style = \"road\",\n  squarify = FALSE,\n  crs = 27700\n)\n```\n\n``` r\noxford_basemap1\n#\u003e class       : SpatRaster \n#\u003e dimensions  : 512, 768, 3  (nrow, ncol, nlyr)\n#\u003e resolution  : 28, 28  (x, y)\n#\u003e extent      : 442585, 464089, 200704, 215040  (xmin, xmax, ymin, ymax)\n#\u003e coord. ref. : OSGB36 / British National Grid (EPSG:27700) \n#\u003e source(s)   : memory\n#\u003e names       : lyr.1, lyr.2, lyr.3 \n#\u003e min values  :     0,     0,     0 \n#\u003e max values  :     1,     1,     1\n```\n\n``` r\nif (requireNamespace(\"tmap\")) {\n  suppressMessages(tmap::tmap_mode(\"plot\"))\n  tmap::tm_shape(oxford_basemap1, raster.downsample = FALSE) +\n    tmap::tm_rgb(max.value = 1)\n}\n#\u003e Loading required namespace: tmap\n```\n\n\u003cimg src=\"man/figures/README-examples-1-tmap-out-1.png\"\nstyle=\"width:100.0%\" /\u003e\n\n``` r\nif (requireNamespace(\"osmdata\", quietly = TRUE)) {\n  oxford2 \u003c- create_bbox(\"Oxford\", 3857)\n} else {\n  oxford2 \u003c- c(\n    xmin = -145188.1,\n    ymin = 6748034.5,\n    xmax = -130890.9,\n    ymax = 6763371.2)\n}\n\noxford_basemap2 \u003c- build_basemap(\n  bbox = oxford2,\n  zoom = 12,\n  style = \"outdoor\",\n  squarify = TRUE,\n  crs = 3857\n)\n```\n\n``` r\noxford_basemap2\n#\u003e class       : SpatRaster \n#\u003e dimensions  : 768, 768, 3  (nrow, ncol, nlyr)\n#\u003e resolution  : 38.21882, 38.21882  (x, y)\n#\u003e extent      : -146760.3, -117408.2, 6741189, 6770541  (xmin, xmax, ymin, ymax)\n#\u003e coord. ref. : WGS 84 / Pseudo-Mercator (EPSG:3857) \n#\u003e source(s)   : memory\n#\u003e names       :      lyr.1,     lyr.2,      lyr.3 \n#\u003e min values  : 0.03137255, 0.1411765, 0.02745098 \n#\u003e max values  : 1.00000000, 1.0000000, 1.00000000\n```\n\n``` r\n# tidyterra: https://dieghernan.github.io/tidyterra/reference/geom_spatraster_rgb.html)\n\nif (requireNamespace(\"ggplot2\") \u0026 requireNamespace(\"tidyterra\")) {\n  ggplot2::ggplot() +\n    tidyterra::geom_spatraster_rgb(\n      data = oxford_basemap2,\n      maxcell = 1e7,\n      max_col_value = 1) +\n    ggplot2::coord_sf() +\n    ggplot2::theme_void()\n}\n#\u003e Loading required namespace: ggplot2\n#\u003e Loading required namespace: tidyterra\n```\n\n\u003cimg src=\"man/figures/README-examples-2-ggplot-1.png\"\nstyle=\"width:100.0%\" /\u003e\n\n### Names API\n\nThe spec for the Names API can be found on the OS website\n[here](https://osdatahub.os.uk/docs/names/technicalSpecification).\n\nCurrently we just use the `find` endpoint. The `nearest` endpoint may be\nadded later.\n\nWithout a `bounds` argument, the function will search nationally. You\ncan specify how many results you want to receive (up to a maximum of\n100).\n\n``` r\n\nquery_names_api(\"Summertown\", local_types = \"Suburban Area\", max_results = 2) |\u003e\n  tibble::glimpse()\n#\u003e Rows: 2\n#\u003e Columns: 28\n#\u003e $ id                    \u003cchr\u003e \"osgb4000000074309758\", \"osgb4000000074546671\"\n#\u003e $ names_uri             \u003cchr\u003e \"http://data.ordnancesurvey.co.uk/id/40000000743…\n#\u003e $ name1                 \u003cchr\u003e \"Summertown\", \"Summertown\"\n#\u003e $ type                  \u003cchr\u003e \"populatedPlace\", \"populatedPlace\"\n#\u003e $ local_type            \u003cchr\u003e \"Suburban Area\", \"Suburban Area\"\n#\u003e $ geometry_x            \u003cdbl\u003e 255845, 451045\n#\u003e $ geometry_y            \u003cdbl\u003e 665095, 208698\n#\u003e $ most_detail_view_res  \u003cint\u003e 6000, 10000\n#\u003e $ least_detail_view_res \u003cint\u003e 25000, 25000\n#\u003e $ mbr_xmin              \u003cdbl\u003e 255457, 450317\n#\u003e $ mbr_ymin              \u003cdbl\u003e 664710, 207986\n#\u003e $ mbr_xmax              \u003cdbl\u003e 256214, 451644\n#\u003e $ mbr_ymax              \u003cdbl\u003e 665574, 209560\n#\u003e $ postcode_district     \u003cchr\u003e \"G51\", \"OX2\"\n#\u003e $ postcode_district_uri \u003cchr\u003e \"http://data.ordnancesurvey.co.uk/id/postcodedis…\n#\u003e $ county_unitary        \u003cchr\u003e \"Glasgow City\", \"Oxfordshire\"\n#\u003e $ county_unitary_uri    \u003cchr\u003e \"http://data.ordnancesurvey.co.uk/id/70000000000…\n#\u003e $ county_unitary_type   \u003cchr\u003e \"http://data.ordnancesurvey.co.uk/ontology/admin…\n#\u003e $ region                \u003cchr\u003e \"Scotland\", \"South East\"\n#\u003e $ region_uri            \u003cchr\u003e \"http://data.ordnancesurvey.co.uk/id/70000000000…\n#\u003e $ country               \u003cchr\u003e \"Scotland\", \"England\"\n#\u003e $ country_uri           \u003cchr\u003e \"http://data.ordnancesurvey.co.uk/id/country/sco…\n#\u003e $ district_borough      \u003cchr\u003e NA, \"Oxford\"\n#\u003e $ district_borough_uri  \u003cchr\u003e NA, \"http://data.ordnancesurvey.co.uk/id/7000000…\n#\u003e $ district_borough_type \u003cchr\u003e NA, \"http://data.ordnancesurvey.co.uk/ontology/a…\n#\u003e $ same_as_geonames      \u003cchr\u003e NA, \"http://sws.geonames.org/2636537\"\n#\u003e $ same_as_dbpedia       \u003cchr\u003e NA, \"http://dbpedia.org/resource/Summertown,_Oxf…\n#\u003e $ geometry              \u003cPOINT [m]\u003e POINT (255845 665095), POINT (451045 208698)…\n```\n\nTo restrict results to a certain area, use the `bounds` argument with a\n“bbox” (the `create_bbox()` function can help you).\n\nUse OS National Grid (CRS 27700) numbers for your bbox.\n\n``` r\n\nquery_names_api(\"Summertown\", \"Suburban Area\", bounds = oxford1) |\u003e\n  tibble::glimpse()\n#\u003e Rows: 1\n#\u003e Columns: 28\n#\u003e $ id                    \u003cchr\u003e \"osgb4000000074546671\"\n#\u003e $ names_uri             \u003cchr\u003e \"http://data.ordnancesurvey.co.uk/id/40000000745…\n#\u003e $ name1                 \u003cchr\u003e \"Summertown\"\n#\u003e $ type                  \u003cchr\u003e \"populatedPlace\"\n#\u003e $ local_type            \u003cchr\u003e \"Suburban Area\"\n#\u003e $ geometry_x            \u003cdbl\u003e 451045\n#\u003e $ geometry_y            \u003cdbl\u003e 208698\n#\u003e $ most_detail_view_res  \u003cint\u003e 10000\n#\u003e $ least_detail_view_res \u003cint\u003e 25000\n#\u003e $ mbr_xmin              \u003cdbl\u003e 450317\n#\u003e $ mbr_ymin              \u003cdbl\u003e 207986\n#\u003e $ mbr_xmax              \u003cdbl\u003e 451644\n#\u003e $ mbr_ymax              \u003cdbl\u003e 209560\n#\u003e $ postcode_district     \u003cchr\u003e \"OX2\"\n#\u003e $ postcode_district_uri \u003cchr\u003e \"http://data.ordnancesurvey.co.uk/id/postcodedis…\n#\u003e $ district_borough      \u003cchr\u003e \"Oxford\"\n#\u003e $ district_borough_uri  \u003cchr\u003e \"http://data.ordnancesurvey.co.uk/id/70000000000…\n#\u003e $ district_borough_type \u003cchr\u003e \"http://data.ordnancesurvey.co.uk/ontology/admin…\n#\u003e $ county_unitary        \u003cchr\u003e \"Oxfordshire\"\n#\u003e $ county_unitary_uri    \u003cchr\u003e \"http://data.ordnancesurvey.co.uk/id/70000000000…\n#\u003e $ county_unitary_type   \u003cchr\u003e \"http://data.ordnancesurvey.co.uk/ontology/admin…\n#\u003e $ region                \u003cchr\u003e \"South East\"\n#\u003e $ region_uri            \u003cchr\u003e \"http://data.ordnancesurvey.co.uk/id/70000000000…\n#\u003e $ country               \u003cchr\u003e \"England\"\n#\u003e $ country_uri           \u003cchr\u003e \"http://data.ordnancesurvey.co.uk/id/country/eng…\n#\u003e $ same_as_geonames      \u003cchr\u003e \"http://sws.geonames.org/2636537\"\n#\u003e $ same_as_dbpedia       \u003cchr\u003e \"http://dbpedia.org/resource/Summertown,_Oxford\"\n#\u003e $ geometry              \u003cPOINT [m]\u003e POINT (451045 208698)\n```\n\n### Features API\n\nThe spec for the Features API can be found on the OS website\n[here](https://osdatahub.os.uk/docs/wfs/technicalSpecification).\n\n`query_features_api()` is designed to work with this API. Unfortunately\nit is not yet functional.\n\nDocumentation to follow.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancisbarton%2Fmapirosa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffrancisbarton%2Fmapirosa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffrancisbarton%2Fmapirosa/lists"}