-
-
Notifications
You must be signed in to change notification settings - Fork 18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use shapes for DTM coverage #169
Open
kbrandwijk
wants to merge
8
commits into
main
Choose a base branch
from
kim/new-dtm-extents
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
8cf6ad9
Use shapes for DTM coverage
kbrandwijk ea13a8b
undo accidental edit
kbrandwijk ddb9120
Add link to source
kbrandwijk c3acd2b
Use lower resolution data for countries to reduce file size and impro…
kbrandwijk 2f16d2c
update link
kbrandwijk 131c745
Generate from online sources directly
kbrandwijk bff115b
Make new boundary extents optional, adding back old _extents property
kbrandwijk 8f4d566
Merge branch 'main' into kim/new-dtm-extents
kbrandwijk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
""" Generate a shapefile with the extents of the regions for all providers. | ||
Source of this data: https://www.naturalearthdata.com/downloads/""" | ||
|
||
import pandas | ||
import shapely | ||
import geopandas | ||
|
||
# prepare state and country files for uniform reading | ||
states = geopandas.read_file("ne_10m_admin_1_states_provinces.zip") | ||
countries = geopandas.read_file("ne_50m_admin_0_countries.zip") | ||
countries.rename(columns={"NAME": "name"}, inplace=True) | ||
|
||
combined = pandas.concat([states, countries]) | ||
|
||
# handling by name (for most of them) | ||
names = [ | ||
"Baden-Württemberg", | ||
"Bayern", | ||
"Canada", | ||
"Czechia", | ||
"Denmark", | ||
"Finland", | ||
"France", | ||
"Hessen", | ||
"Italy", | ||
"Mecklenburg-Vorpommern", | ||
"Niedersachsen", | ||
"Norway", | ||
"Nordrhein-Westfalen", | ||
"Sachsen-Anhalt", | ||
"Spain", | ||
"Switzerland", | ||
"United States of America", | ||
"Antarctica", | ||
] | ||
names_set = combined[combined["name"].isin(names)] | ||
|
||
# handling by state/province | ||
england_set = combined[combined["geonunit"] == "England"] | ||
union = shapely.union_all(england_set["geometry"]) | ||
england_union = geopandas.GeoDataFrame(columns=["name", "geometry"], data=[["England", union]]) | ||
|
||
scotland_set = combined[combined["geonunit"] == "Scotland"] | ||
union = shapely.union_all(scotland_set["geometry"]) | ||
scotland_union = geopandas.GeoDataFrame(columns=["name", "geometry"], data=[["Scotland", union]]) | ||
|
||
flanders_set = combined[combined["region"] == "Flemish"] | ||
union = shapely.union_all(flanders_set["geometry"]) | ||
flanders_union = geopandas.GeoDataFrame(columns=["name", "geometry"], data=[["Flanders", union]]) | ||
|
||
# manual bounds that don't correspond to a specific country | ||
srtm = geopandas.GeoDataFrame({"name": ["SRTM"], "geometry": [shapely.box(-180, -90, 180, 90)]}) | ||
|
||
# Arctic is a special case | ||
arctic_names = [ | ||
"Canada", | ||
"Sweden", | ||
"Finland", | ||
"Iceland", | ||
"Norway", | ||
"Russia", | ||
"United States of America", | ||
"Greenland", | ||
] | ||
arctic_set = combined[combined["name"].isin(arctic_names)] | ||
union = shapely.union_all(arctic_set["geometry"]) | ||
arctic_clipped = shapely.clip_by_rect( | ||
union, -180, 60.7492704708152, 179.99698443265999, 83.98823036056658 | ||
) | ||
arctic = geopandas.GeoDataFrame(columns=["name", "geometry"], data=[["Arctic", arctic_clipped]]) | ||
|
||
# combine all | ||
result = pandas.concat([names_set, england_union, scotland_union, flanders_union, arctic, srtm])[ | ||
["name", "geometry"] | ||
] | ||
|
||
result.to_file( | ||
"../maps4fs/generator/dtm/extents.shz", | ||
driver="ESRI Shapefile", | ||
) |
iwatkot marked this conversation as resolved.
Show resolved
Hide resolved
|
Binary file not shown.
iwatkot marked this conversation as resolved.
Show resolved
Hide resolved
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,4 +23,5 @@ tqdm | |
types-tqdm | ||
scipy | ||
schedule | ||
streamlit-folium | ||
streamlit-folium | ||
geopandas |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we automatically retrieve this list somewhere? Providers?
Why it's hardcoded?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like iterating over the DTM Provider subclasses and parse their names or something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well they are not all treated the same so if we want to iterate over the providers automatically, then how do we treat some differently (like England, Scotland and the others in there)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kbrandwijk, can't we somehow make it in a universal way? So we don't need some weird list of strings and so on, just hit F5 and we're ready to go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately not. Some providers don't match 1-on-1 with a country, so some need special handling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kbrandwijk, can we implement somehow this special handling as a property or a method of a DTM Provider class?
The thing is: when I'm looking here I see a big red text: no one will evar be able to implement their own DTM Provider unless they developed this feature with extent. 🤣
And that worries me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That'd be nice actually to move this to the provider classes. I can just iterate over provider subclasses like we already do, and if there's a method defined to extract the data, we use it, otherwise we do it by name.