gadm
gadm(country, subregions...; children=false, names=false, children_raw=false, alllevels=false, reportlevels=false)Returns a GMTdataset for the requested country, or country subregion(s)
country: ISO 3166 Alpha 3 country code.subregions: Full official names in hierarchial order (provinces, districts, etc…). To know the names of all administrative children of parent, use the optionnames.children: When true, function returns all subregions of parent.children_raw: When true, function returns two variables -> parent, children, where children is a GDAL object E.g. when children is set to true and when querying just the country, second return parameter are the states/provinces. Ifchildrenwe return a Vector of GMTdataset with the polygons. Ifchildren_rawthe second output is a GDAL object much like in GADM (less the Tables.jl)names: Return a string vector with allchildrennames.alllevels: When true, return the requested unit AND every administrative level below it: its children, their children, and so on down to the deepest level that country has. The whole thing comes out of a single read of the country file, which is what makes it usable: asking level by level withchildrenre-opens and re-scans that file once per unit, so a country with parishes (Portugal: 18 districts and 308 municipalities) costs hundreds of full reads instead of one. Each returned polygon carries its own GADM record inattrib, so which unit it is (NAME_1,NAME_2, …) is read off the result itself.reportlevels: just report the number of administrative levels (including the country) and exit.
Credits
Addapted from the original GADM (MIT Licensed) and stripped from all of it’s dependencies (ArchGDAL repaced by the GMT GDAL functions). Expanded to also return all subregions of a particular administrative entity.
Examples
# data of India's borders
data = gadm("IND")
# uttar -> the limits of the Uttar Pradesh state
uttar = gadm("IND", "Uttar Pradesh")
# uttar -> limits of all districts of the Uttar Pradesh state
uttar = gadm("IND", "Uttar Pradesh", children=true)
# Names of all states of India
gadm("IND", names=true)
# Every level below Uttar Pradesh: the state, its districts, and each district's own subdivisions
uttar = gadm("IND", "Uttar Pradesh", alllevels=true)
# The same for a whole country (Portugal: districts, municipalities and parishes, in one read)
pt = gadm("PRT", alllevels=true)Source Code
View the source code for this function.