Listing polygon properties
This page gives an overview of the methods to get access to additional information stored in the polygon data.
using SpeciesDistributionToolkitWe will select the Countries dataset from NaturalEarth as our example:
polydata = PolygonData(NaturalEarth, Countries)PolygonData{NaturalEarth, Countries}()These data can be retrieved with getpolygon:
pol = getpolygon(polydata)FeatureCollection with 258 features, each with 4 propertiesThis returns the complete dataset, which is almost always a lot more polygons that we want. To figure out which polygons are relevant, we need to inspect the properties attached to each:
keys(uniqueproperties(pol))KeySet for a Dict{String, Vector} with 4 entries. Keys:
"Population"
"Subregion"
"Name"
"Region"Note that by default, the Name key can be used directly:
pol["Ghana"]Polygon Feature
├ Region => Africa
├ Subregion => Western Africa
├ Name => Ghana
└ Population => 30417856We will look at which regions are available here:
uniqueproperties(pol)["Region"]6-element Vector{String}:
"Asia"
"Americas"
"Africa"
"Europe"
"Oceania"
"Antarctica"Getting the countries for Africa is therefore:
pol["Region" => "Africa"]FeatureCollection with 62 features, each with 4 propertiesWe can apply the uniqueproperties function to the object that is returned here, for example to list all available sub-regions:
uniqueproperties(pol["Region" => "Africa"])["Subregion"]6-element Vector{String}:
"Eastern Africa"
"Northern Africa"
"Middle Africa"
"Southern Africa"
"Western Africa"
"Seven seas (open ocean)"We can now get all of the polygons in the region of Africa that are in the sub-region of Eastern Africa with:
eastern_afr = pol["Region" => "Africa"]["Subregion" => "Eastern Africa"]FeatureCollection with 19 features, each with 4 propertiesRelated documentation
Missing docstring.
Missing docstring for uniqueproperties. Check Documenter's build log for details.
Missing docstring.
Missing docstring for getpolygon. Check Documenter's build log for details.