SpatialJoin
Like SpatialQuery, SpatialJoin retrieves a list of features. It also retrieves information about related features for every feature in the result:
- Get counties within 10 miles of a point, and get the count of Superfund sites within each county.
- Get US states, and get a list of IDs of counties in each state that have at least 2,000 Presbyterian adherents.
Table of Contents
The Basics
Using this document
This document assumes some knowledge of SpatialQuery, which shares many arguments with SpatialJoin. The shared arguments are documented in SpatialQuery syntax.
The examples in this document are not URL-escaped, so they will not work directly in the browser. Make sure to properly escape your URLs.
Similarities with SpatialQuery
Like SpatialQuery, SpatialJoin retrieves a list of features, but has some limitations and extra capabilities. SpatialJoin does not permit the 'aggregate' argument, nor does it permit selecting data from attribute tables. Also, SpatialJoin requests are limited to a single geometry dataset in the 'from' arguments. See SpatialQuery syntax for details.
What Do I Get Back?
SpatialJoin retrieves a list of features, along with the count of related features and/or a list of their IDs. If you need additional fields of related features, you can use FeatureQuery to retrieve them.
Constructing URLs
Base Path
The base path for SpatialJoin requests is:
http://spatial.mapfluence.com/spatialjoin.<format>
where <format> is either json or geojson and specifies the reponse format.
join (required)
Use 'join' to specify the related geometry dataset. To retrieve counties along with the count of US Census block groups in each county:
select=COUNT from=us_census00.county_geom join=us_census00.blkgrp_geom
on
Use 'on' to perform data filters on the 'join' geometry dataset. To get states and a list of IDs of airports with at least 1,000,000 enplanements in each state:
select=IDS from=us_census00.state_geom join=ntad_airports.arpt_loc_geom on=ntad_airports.arpt_loc.tot_enplane__gt:1000000+ntad_airports.arpt_loc.fac_type:'Airport'
Inherited Arguments
select
SpatialJoin adds two select options: 'COUNT' and 'IDS'. COUNT will return the count of related features and IDS will return a list of IDs. You can use either COUNT or IDS or both, separated by ';' as normal. You may also use 'select' to limit which of the built-in fields are returned, as in SpatialQuery.
See SpatialQuery select.
where
See SpatialQuery where.
limit
See SpatialQuery limit.