When working with osdatahub
you will notice that some of
the functions using extents have an argument called crs
.
For example when creating a bounding box you need to specify a CRS like
this:
The second argument in extent_from_bbox
is called CRS,
which stands for “coordinate reference system”. A CRS is needed when
processing geographic data in order to manipulate the coordinates.
Typically you won’t need to know much about the CRS when using
osdatahub
, but there are some common “gotchas” which we
will describe here.
A CRS may sometimes be referred to as a SRS (spatial reference system) but they are the same thing.
In osdatahub
the CRS is specified as a string in the
following format “epsg:27700”. EPSG stands for European Petroleum Survey
Group and 27700 represents the CRS which Ordnance Survey commonly uses.
CRS values used in osdatahub
are: EPSG:27700, EPSG:4326,
EPSG:7405, EPSG:3857, and CRS84.
A full description of CRS is not needed to use osdatahub
but if you are interested in that kind of thing this link is useful for
grounding your understanding https://datacarpentry.org/organization-geospatial/03-crs/.
The most likely pitfall, due to CRS, you may encounter relates to
specifying your extent when creating it for osdatahub.
For example, this is a bounding box is for a portion of Westminster
But a very common mistake is to specify the coordinates in a different CRS to the CRS passed to the function. Suppose we made the following error.
Here we have given the coordinates in the CRS 27700 (eastings and northings measured in metres); however we’ve mistakenly specified the CRS as 4326. The same coordinates in different CRS can represent different locations. For this example, the bounding box is actually somewhere in the arctic circle, and consequently any query for OS data in this region would return an error.
A good way to check if you are using the correct CRS for your coordinates is to ensure the coordinates fall within a sensible range.
This means its pretty easy to see if you are using BNG when you should be WGS84 or Pseudo-Mercator. Differentiating between WGS84, CRS84, and Pseudo-Mercator can’t be done with this check and will require you to check which CRS you want.
Another common source of confusion with CRS is EPSG:4326 (aka WGS84) vs. CRS84. Both of these systems are for mapping coordinates measured in latitude and longitude degrees, but they have their axes in different orders! Specifically, CRS84 defines positions as always (longitude, latitude) order, while ESPG:4326 defines positions in (latitude, longitude) order.
The axis ordering makes a difference for how you define extents with
osdatahub
. When using EPSG:4326 and latitude/longitude
order, the extent should also be defined in that order, where the x-axis
is your first coordinate axis and the y-axis is your second coordinate
axis.