SensorID | Latitude | Longitude |
---|---|---|
1 | 51.5070 | -0.1347 |
2 | 51.5071 | -0.0042 |
3 | 51.5074 | -0.1223 |
4 | 51.5073 | -0.1122 |
5 | 51.5072 | 0.1589 |
Sjoin adds an operator (['intersects','contains','within']
) and example code can be found on GitHub.
Changing how to left
, right
, or inner
changes the join’s behaviour:
These merge operators apply where a
is the left set of features (in a GeoSeries or GeoDataFrame) and b
is the right set:
True
if no points of b lie outside of a and at least one point of b lies inside a.True
if a’s boundary and interior intersect only with the interior of b (not its boundary or exterior).True
if the boundary or interior of a intersects in any way with those of b.All binary predicates are supported by features of GeoPandas, though only these three options are available in sjoin
directly.
These operators apply to the GeoSeries where a
is a GeoSeries and b
is one or more spatial features:
Series
of dtype('bool')
with value True
for each geometry in a
that contains b
. These are different.Series
indicating which elements of a
touch a point on b
.Series
containing the distance from all a
to some b
.Series
indicating which elements of a
do not intersect with any b
.a
and b
in terms of their geometry.a
In particular, “contains” (and its converse “within”) has an aspect of its definition which may produce unexpected behaviour. This quirk can be expressed as “Polygons do not contain their boundary”. More precisely, the definition of contains is: Geometry A contains Geometry B iff no points of B lie in the exterior of A, and at least one point of the interior of B lies in the interior of A That last clause causes the trap – because of it, a LineString which is completely contained in the boundary of a Polygon is not considered to be contained in that Polygon! This behaviour could easily trip up someone who is simply trying to find all LineStrings which have no points outside a given Polygon. In fact, this is probably the most common usage of contains. For this reason it’s useful to define another predicate called covers, which has the intuitively expected semantics: Geometry A covers Geometry B iff no points of B lie in the exterior of A
It is also possible to apply GIS-type ‘overlay’ operations:
These operations return indexes for gdf1
and gdf2
(either could be a NaN
) together with a geometry and (usually?) columns from both data frames:
The set of operations includes: union
, intersection
, difference
, symmetric_difference
, and identity
.
As your data grows in volume, the consequences of choosing the ‘wrong’ approach become more severe. Making a plan of attack becomes essential and it boils down to the following:
So, when you have multiple joins…
Q. Find me a nearby family-style Italian restaurant…
A. Here’s how I’d do this:
Keep in mind:
With complex geometries and mis-matched scales, converting the smaller geometry to centroids or representative points can speed things up a lot (within, contains, etc. become much simpler).
And that:
With large data sets, rasterising the smaller and more ‘abundant’ geometry can speed things up a lot.
Acronym | Means | Does |
---|---|---|
WMS | Web Map Service | Transfers map images within an area specified by bounding box; vector formats possible, but rarely used. |
WFS | Web Feature Service | Allows interaction with features; so not about rendering maps directly, more about manipulation. |
WCS | Web Coverage Service | Transfers data about objects covering a geographical area. |
OWS | Open Web Services | Seems to be used by QGIS to serve data from a PC or server. |
There are many flavours:
Generally:
Linking Spatial Data • Jon Reades