-
Notifications
You must be signed in to change notification settings - Fork 1
Add How to guide for GADM data sets #22
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
Closed
Closed
Changes from all commits
Commits
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 hidden or 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,61 @@ | ||
How to use political borders from GADM | ||
--------------------------------------- | ||
|
||
GADM (https://gadm.org/) is a project that provides spatial data for all countries and their sub-divisions. | ||
They allow you to freely use their data (see `license <https://gadm.org/license.html>`_) to make your own maps. | ||
You can use this script to download the data from their server. | ||
You only need to select a data set (using a three-letter code) and a level. | ||
Not all levels are available. Check first in their website if the data set exists. | ||
Here is a table with the number of file available for each level. | ||
|
||
======= ============ | ||
Level # of files | ||
======= ============ | ||
0 254 | ||
1 230 | ||
2 171 | ||
3 69 | ||
4 21 | ||
5 2 | ||
======= ============ | ||
|
||
The script will download the selected data and level in KMZ format. | ||
Then, it will unzip that file (to KML) and convert it to a GMT format. | ||
At the end, you will have a GMT file in the same directory. | ||
To demostrate, we will create a level 1 map of Mexico (code MEX). | ||
|
||
.. gmtplot:: | ||
|
||
# How to plot political borders from GADM data set | ||
# | ||
# GDAM data | ||
# ------------------------------------ | ||
# Set country with three-leter code. | ||
COUNTRY=MEX | ||
# Set level from 0 to 5. 0 = Country outline. | ||
LEVEL=1 | ||
# GADM data set version | ||
VERSION=4.1 | ||
# File formats (https://gadm.org/formats.html) | ||
FORMAT=kmz | ||
SITE="https://geodata.ucdavis.edu/gadm/" | ||
# Remove dot from version | ||
VERSION_WITHOUT_DOT=$(echo ${VERSION} | tr -d '.') | ||
# Set file name without extension | ||
NAME="gadm${VERSION_WITHOUT_DOT}_${COUNTRY}_${LEVEL}" | ||
# URL | ||
URL="${SITE}gadm${VERSION}/${FORMAT}/${NAME}.${FORMAT}" | ||
# ------------------------------------ | ||
# Download data from GADM | ||
echo "Downloading geographic data provided by the https://gadm.org project. It may take a while." | ||
gmt which $URL -Gc | ||
# Unzip KMZ to KML. Set to NOT (-n) overwrite existing file. | ||
unzip -n ${NAME}.${FORMAT} | ||
# Convert KML file to GMT format with OGR/GDAL | ||
ogr2ogr -f "GMT" ${NAME}.gmt ${NAME}.kml | ||
# Test Plot data | ||
gmt begin ${COUNTRY} png | ||
gmt plot ${NAME}.gmt -Wred -JM15c -Bf -Re | ||
gmt end | ||
# Delete KMZ and KML files | ||
rm ${NAME}.km? |
This file contains hidden or 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 | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -54,7 +54,6 @@ Lines | |||||||||||||||||||||||||||||||||
Vectors | ||||||||||||||||||||||||||||||||||
~~~~~~~ | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Symbols and markers | ||||||||||||||||||||||||||||||||||
~~~~~~~~~~~~~~~~~~~ | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
@@ -79,6 +78,15 @@ Seismology and geodesy | |||||||||||||||||||||||||||||||||
Basemaps | ||||||||||||||||||||||||||||||||||
~~~~~~~~ | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
.. cssclass:: gmtgallery | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
- .. image:: _images/7dd36e07258e1015a0673dea4e472db1.png | ||||||||||||||||||||||||||||||||||
:target: gallery/maps/gadm.html | ||||||||||||||||||||||||||||||||||
:width: 80% | ||||||||||||||||||||||||||||||||||
:align: center | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
:doc:`gallery/maps/gadm` | ||||||||||||||||||||||||||||||||||
Comment on lines
+81
to
+88
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. You don't need to open a separate PR #29, just need to update the following lines:
Suggested change
|
||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
Histograms | ||||||||||||||||||||||||||||||||||
~~~~~~~~~~ | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
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.
Need to update the gallery after #28
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.
I am bit confused about how to do it. I will cancel this PR and make a new one.