JuliaGeo / GADM.jl

A Julia package for obtaining geographical data from the GADM dataset
https://gadm.org
MIT License
38 stars 4 forks source link

Getting lower level regions (e.g. all counties of the US) #40

Closed greimel closed 2 years ago

greimel commented 3 years ago

Is there a better way of getting all counties of the US than this?

country_code = "USA"
lev0, lev1 = GADM.get(country_code, children = true)
lev1_ids = lev1.NAME_1
mapreduce(vcat, lev1_ids) do id1
    _, lev2 = GADM.get(country_code, id1, children = true)
    lev2 |> DataFrame
end

It would be nice to have something like

GADM.get("USA", level = 2)
juliohm commented 3 years ago

It seems like a nice addition @greimel . Maybe we should reconsider the option children as well to mean level=1? I wonder how the new API will look like. Maybe we set level=0 by default and specify levels that are non zero to go deeper in the tree?

If you have time to work on a PR I"d be happy to review.

juliohm commented 2 years ago

Fixed on master with a new option depth thanks to @ClaroHenrique 👍🏽