SpatialPointSelect[spdata,crit]
selects a subset of the SpatialPointData spdata according to crit.
SpatialPointSelect
SpatialPointSelect[spdata,crit]
selects a subset of the SpatialPointData spdata according to crit.
Details
- SpatialPointSelect is typically used to get a smaller SpatialPointData with some parts selected.
- Conceptually, SpatialPointSelect acts as a Select on points and annotations of the form {{point1,ann1},{point2,ann2},…} to select a subpart.
-
- The criterion function crit is typically a Boolean expression with conditions on points and annotations, such as (Norm[#Point]<1&& #species"Birch")& if species was one of the annotation keys.
-
- The following arguments can be used in crit:
-
#Point conditions on point #key conditions on values associated with the annotation "key"
Examples
open all close allBasic Examples (2)
spd = SpatialPointData[RandomReal[1, {100, 2}], Rectangle[{0, 0}, {1, 1}]]Plot points in the observation region:
Show[RegionPlot[spd["ObservationRegion"]], ListPlot[spd["Points"]]]Select points in a smaller rectangle:
sub = SpatialPointSelect[spd, Element[#Point, Rectangle[{0, 0}, {1 / 2, 1}]]&]Show[RegionPlot[spd["ObservationRegion"]], ListPlot[sub["Points"]]]Select points based on latitude condition:
spd = SpatialPointData[RandomGeoPosition[GeoBoundsRegion[{{-23.43, 23.43}, {-180, 180}}], 100]]Select points on or above the equator:
sub = SpatialPointSelect[spd, #Point["Latitude"] ≥ 0&]GeoListPlot /@ {spd["Points"], sub["Points"]}Scope (7)
By Point Condition (5)
Select points that are within a given region:
spd = SpatialPointData[RandomReal[1, {100, 2}], Rectangle[]];Show[RegionPlot[{spd["ObservationRegion"]}], ListPlot[spd["Points"]]]reg = Disk[{0, 0}, .5];
sub = SpatialPointSelect[spd, Element[#Point, reg]&]Show[RegionPlot[{sub["ObservationRegion"], reg}], ListPlot[sub["Points"]]]Pick out points with norm less than 1/2:
spd = SpatialPointData[RandomReal[1, {5000, 2}]]pts1 = ListPlot[spd["Points"], AspectRatio -> 1]Define the selection criterion:
crit = Norm[#Point] < 1 / 2&;sub = SpatialPointSelect[spd, crit]Plot the original data with the selected subset:
Show[pts1, ListPlot[sub["Points"], PlotStyle -> Orange]]Pick all points with first coordinate greater than 1/3:
spd = SpatialPointData[RandomReal[1, {100, 2}]]Define the selection condition:
cond = First[#Point] > 1 / 3&;sub = SpatialPointSelect[spd, cond]Plot the original data with the selected subset:
Show[ListPlot[spd["Points"], PlotStyle -> PointSize[0.03]], ListPlot[sub["Points"], PlotStyle -> {Orange, PointSize[0.015]}], AspectRatio -> 1]Select points based on geo location:
spd = SpatialPointData[RandomGeoPosition[GeoBoundsRegion[{{0, 90}, {-180, 0}}], 100]];GeoListPlot[spd["Points"]]Select locations within 2000 kilometers of Chicago:
sub = SpatialPointSelect[spd, GeoDistance[#Point, Entity["City", {"Chicago", "Illinois", "UnitedStates"}]["Position"]] < Quantity[2000, "km"]&]GeoListPlot[sub["Points"]]Extract a subset of the data close to a region:
data = RandomReal[1, {500, 2}];
reg = Rectangle[];spd = SpatialPointData[data, reg]areaOfInterest = Rectangle[{1, .3}, {1.5, .5}];sub = SpatialPointSelect[spd, (0 < RegionDistance[areaOfInterest, #Point] < .2)&]Graphics[{{Opacity[.1], spd["ObservationRegion"]}, {Opacity[.3], areaOfInterest}, {ColorData[97, 1], Point[spd["Points"]]}, {ColorData[97, 2], Point[sub["Points"]]}, Inset[Style["reg", Bold], {0.05, 0.05}], Inset[Style["Area of Interest", Bold], {1.25, 0.4}]}]By Annotation (2)
Keep selected points based on annotation value:
pts = RandomReal[1, {10, 2}];
reg = Rectangle[{0, 0}, {1, 1}];colors = RandomChoice[ColorData[97, "ColorList"], 10];
diameters = RandomReal[{0, 1 / 3}, 10];spd = SpatialPointData[pts -> {"color" -> colors, "diameter" -> diameters}, reg]spd["Annotations"]Select points for which "color" annotation value is close to Red:
sub = SpatialPointSelect[spd, (ColorDistance[#color, Red] < .7)&]Show annotations of the remaining points:
sub["Annotations"]Select points based on selected annotation value:
pts = RandomReal[1, {10, 2}];
reg = Rectangle[{0, 0}, {1, 1}];colors = RandomChoice[ColorData[97, "ColorList"], 10];
diameters = RandomReal[{0, 1 / 3}, 10];spd = SpatialPointData[pts -> {"color" -> colors, "diameter" -> diameters}, reg]spd["Annotations"]sub = SpatialPointSelect[spd, #diameter ≥ .1&]Show annotations of the subset:
sub["Annotations"]Applications (1)
Locations of breweries in the US:
data = SpatialPointData[«2»];The observation region has been inferred from the locations:
GeoGraphics[data["ObservationRegion"]]Find latitude and longitude bounds for the contiguous US:
reg = EntityValue[GeoVariant[Entity["Country", "UnitedStates"], "DefaultMapArea"], "Polygon"];{{minLat, maxLat}, {minLon, maxLon}} = GeoBounds[reg]selected = SpatialPointSelect[data, And[minLat <= (#Point["Latitude"]) <= maxLat&, minLon <= (#Point["Longitude"]) <= maxLon&]]SpatialPointSelect preserves the original observation region:
selected["ObservationRegion"] == data["ObservationRegion"]Create new spatial point data with selected points and smaller observation region:
breweries = SpatialPointData[selected["Points"], reg]GeoGraphics[{Point[breweries["Points"]], Red, breweries["ObservationRegion"]}]See Also
Related Guides
History
Text
Wolfram Research (2020), SpatialPointSelect, Wolfram Language function, https://reference.wolfram.com/language/ref/SpatialPointSelect.html.
CMS
Wolfram Language. 2020. "SpatialPointSelect." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/SpatialPointSelect.html.
APA
Wolfram Language. (2020). SpatialPointSelect. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/SpatialPointSelect.html
BibTeX
@misc{reference.wolfram_2026_spatialpointselect, author="Wolfram Research", title="{SpatialPointSelect}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/SpatialPointSelect.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_spatialpointselect, organization={Wolfram Research}, title={SpatialPointSelect}, year={2020}, url={https://reference.wolfram.com/language/ref/SpatialPointSelect.html}, note=[Accessed: 13-June-2026]}