-
Notifications
You must be signed in to change notification settings - Fork 2
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
Update WDPA processing #12
Open
brynpickering
wants to merge
14
commits into
main
Choose a base branch
from
update-wdpa-processing
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 1 commit
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b4073a5
Added wdpa-date config & new WDPA processing
6257420
Fixes all over the place
2138170
Remove temporary WDPA files
c0772bd
Update WDPA extraction and merging
c1496ad
Suppress all errors with ogrmerge
773d15d
Merge branch 'main' into update-wdpa-processing
e9137b0
Process points and polys at the same time
9589577
Remove excessive whitespace & unnecessary imports
99461f3
Merge branch 'main' into update-wdpa-processing
b8e77bd
Update WDPA processing to match current main
a8f04a0
Add new util tests
67c84f6
Merge branch 'main' into update-wdpa-processing
2b791b3
Update schema
585ec63
Updates following review
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ URL_NUTS = "https://ec.europa.eu/eurostat/cache/GISCO/distribution/v2/nuts/shp/N | |
URL_LAU = "http://ec.europa.eu/eurostat/cache/GISCO/geodatafiles/COMM-01M-2013-SH.zip" | ||
URL_DEGURBA = "http://ec.europa.eu/eurostat/cache/GISCO/geodatafiles/DGURBA_2014_SH.zip" | ||
URL_LAND_COVER = "http://due.esrin.esa.int/files/Globcover2009_V2.3_Global_.zip" | ||
URL_PROTECTED_AREAS = "https://www.protectedplanet.net/downloads/WDPA_Feb2019?type=shapefile" | ||
URL_PROTECTED_AREAS = "http://d1gam3xoknrgr2.cloudfront.net/current/WDPA_{}_Public_shp.zip" | ||
URL_CGIAR_TILE = "http://srtm.csi.cgiar.org/wp-content/uploads/files/srtm_5x5/TIFF/" | ||
URL_GMTED_TILE = "https://edcintl.cr.usgs.gov/downloads/sciweb1/shared/topo/downloads/GMTED/Global_tiles_GMTED/075darcsec/mea/" | ||
URL_GADM = "https://biogeo.ucdavis.edu/data/gadm3.6/gpkg/" | ||
|
@@ -135,17 +135,38 @@ rule raw_land_cover: | |
rule raw_protected_areas_zipped: | ||
message: "Download protected areas data as zip." | ||
output: protected("data/automatic/raw-wdpa.zip") | ||
shell: "curl -sLo {output} -H 'Referer: {URL_PROTECTED_AREAS}' {URL_PROTECTED_AREAS}" | ||
params: | ||
url = URL_PROTECTED_AREAS.format(config["parameters"]["wdpa-date"]) | ||
shell: "curl -sLo {output} -H 'Referer: {params.url}' {params.url}" | ||
brynpickering marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
rule raw_protected_areas: | ||
message: "Extract protected areas data as zip." | ||
input: rules.raw_protected_areas_zipped.output | ||
params: | ||
year = config["parameters"]["wdpa-date"] | ||
brynpickering marked this conversation as resolved.
Show resolved
Hide resolved
|
||
output: | ||
polygons = "build/raw-wdpa-feb2019/WDPA_Feb2019-shapefile-polygons.shp", | ||
polygon_data = "build/raw-wdpa-feb2019/WDPA_Feb2019-shapefile-polygons.dbf", | ||
points = "build/raw-wdpa-feb2019/WDPA_Feb2019-shapefile-points.shp" | ||
shell: "unzip -o {input} -d build/raw-wdpa-feb2019" | ||
polygons = "build/raw-wdpa/wdpa-shapes.shp", | ||
polygon_data = "build/raw-wdpa/wdpa-shapes.dbf", | ||
brynpickering marked this conversation as resolved.
Show resolved
Hide resolved
|
||
points = "build/raw-wdpa/wdpa-points.shp" | ||
conda: "../envs/default.yaml" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This conda env is useless here. |
||
shell: | ||
""" | ||
set +e | ||
unzip -o {input} -d build/raw-wdpa | ||
brynpickering marked this conversation as resolved.
Show resolved
Hide resolved
|
||
unzip -o build/raw-wdpa/WDPA_{params.year}-shapefile0.zip -d build/raw-wdpa/WDPA_to_merge_0 | ||
brynpickering marked this conversation as resolved.
Show resolved
Hide resolved
|
||
unzip -o build/raw-wdpa/WDPA_{params.year}-shapefile1.zip -d build/raw-wdpa/WDPA_to_merge_0 | ||
unzip -o build/raw-wdpa/WDPA_{params.year}-shapefile2.zip -d build/raw-wdpa/WDPA_to_merge_0 | ||
ogrmerge.py -single -o {output.polygons} build/raw-wdpa/WDPA_to_merge_**/*-polygons.shp | ||
brynpickering marked this conversation as resolved.
Show resolved
Hide resolved
|
||
ogrmerge.py -single -o {output.polygons} build/raw-wdpa/WDPA_to_merge_**/*-points.shp | ||
brynpickering marked this conversation as resolved.
Show resolved
Hide resolved
|
||
exitcode=$? | ||
brynpickering marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if [ $exitcode -eq 1 ] | ||
then | ||
exit 1 | ||
else | ||
exit 0 | ||
fi | ||
""" | ||
|
||
|
||
rule raw_srtm_elevation_tile_zipped: | ||
|
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.
This could check for the form
MMMYYYY
, but maybe that's just too restrictive.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.
yeah, who knows how they'll choose to do versioning in future...