getbyattrib
getbyattrib(D::Vector{<:GMTdataset}[, index::Bool=false]; kw...)
or
filter(D::Vector{<:GMTdataset}; kw...)
or
findall(D::Vector{<:GMTdataset}; kw...)
Take a GMTdataset vector and return only its elements that match the condition(s) set by the kw
keywords. Note, this assumes that D
has its attrib
fields set with usable information.
NOTE: Instead of getbyattrib
one can use instead filter
(..., index=false
) or findall
(..., index=true
)
attrib name(s)=value(s)
: Easier to explain by examples:NAME="Antioquia"
, select all elements that have that attribute/value combination.NAME=("Antioquia", "Caldas")
, picks elements that have thoseNAME
attributes. Add as many as wished. If using twokwargs
the second works as a condition.(..., NAME=("Antioquia", "Caldas"), feature_id=0)
means select all elements fromAntioquia
andCaldas
that have the attributefeature_id
= 0.A second set of attributes can be used to select elements by region, number of polygon vertices and area. For that, name the keyword with a leading underscore, e.g.
_region
,_nps
,_area
,_unique
. Their values are passed respectively a 4 elements tuple and numbers. E.g._region=(-8.0, -7.0, 37.0, 38.0)
,_nps=100
,_area=10
. Areas are in square km when input is in geographic coordinates, otherwise squre data unites. The_unique
case is a bit special and is meant to be used when more than one polygon share the same attribute value (e.g. countries with islands). In that case, set the value of_unique
to the name of the attribute that is shared by the polygons (e.g._unique="NAME"
). By default (e.g._unique=true
), the attribute name isFeature_ID
which is the one used by GMT when creating unique IDs for polygons read from OGR formats (.shp, .geojson, etc). If this attrib name is not found, we search forCODE
which is the one assigned by GMT when extracting polygons from the internal GMT coasts database. If none of these is found, it is users responsibility to provide a valid attribute name. The uniqueness is determined by selecting the polygon with the largest area.attrib
oratt
: (OLD SYNTAX) A NamedTuple with the attribname, attribvalue as inatt=(NAME_2="value",)
. Use more elements if wishing to do a composite match. E.g.att=(NAME_1="val1", NAME_2="val2")
in which case only segments matching the two conditions are returned.index
: Use thispositional
argument =true
to return only the segment indices that match theatt
condition(s).
Returns
Either a vector of GMTdataset, or a vector of Int with the indices of the segments that match th query condition. Or nothing
if the query results in an empty GMTdataset
Examples
D = filter(D, NAME_2="Porto");
D = filter(D, _region="(-8.0, -7.0, 37.0, 38.0)", _nps=100);
See Also
These docs were autogenerated using GMT: v1.33.0