Skip to content

Conversation

@PaulWessel
Copy link
Member

@PaulWessel PaulWessel commented Nov 27, 2021

DCW collections are named groups of countries (or states) that can be requested via their abbreviation or full name. DCW 2.0.2 will ship with some standard collections but users can add their own in _~/.gmt/dcw-groups.txt which must have the format

# Any number of comments anywhere in the file
tag: abbreviation [full name]
XX,YY,ZZ,WW,...

where the XX,YY etc are valid DCW tags. Any number of tag/list sequences are allowed. As a simple example, these two lines adds the collection of Scandinavian countries:

tag: SCA Scandinavia
NO,SE,DK

Once can then use the collection in one of two ways:

gmt coast -RSCA -Gred -B -pdf map
gmt coast -RScandinavia -Gred -B -pdf map

While deveopers will work on suitable collections to distribute as offical names, interested users can play with this branch and create collections as described. I have placed an empty dcw-collections.txt file on the data server so that we avoid errors when GMT tries to download a missing system file.

For now there is no listing option provided, but this will come later. Closes #5742.

DCW collections are named groups of countries (or states) that can be requested via their abbreviation or full name.  DCW will ship with some standard collections but users can add their own in ~/.gmt/dcw-collections.txt which has the format

# ANy number of comments
tag: abbreviation [full name]
XX,YY,ZZ,WW,...

where the XX etc are valid DCW tags. Any number of tag/list sequences are allowed.
@PaulWessel PaulWessel added the enhancement Improving an existing feature label Nov 27, 2021
@PaulWessel PaulWessel requested review from Esteban82 and anbj November 27, 2021 02:59
@PaulWessel PaulWessel self-assigned this Nov 27, 2021
@PaulWessel
Copy link
Member Author

I added a listing modifier +n to list available collections, i.e.

gmt coast -E+n

If you give a country or countries it will only list collections that contains that country:

gmt coast -ENO+n

should find Scandinavia, Nordic Countries, etc. This assume there are such collections of course

@Esteban82
Copy link
Member

Esteban82 commented Nov 28, 2021

Great Paul

BTW, I try to use "" for the names and I get an error:

# Central America
tag: CAM "CentralAmerica"
BZ,CR,HN,GT,NI,PA,SV

gmt coast -R"CentralAmerica" -Gred -B -png mapa
coast [WARNING]: No country code matching CentralAmerica (skipped)

@PaulWessel
Copy link
Member Author

Try no quotes inside the file, and only use quotes if there are spaces on the command line.

@Esteban82
Copy link
Member

Try no quotes inside the file, and only use quotes if there are spaces on the command line.

Great. Now works.

For the record:

# Central America
tag: CAM Central America
BZ,CR,HN,GT,NI,PA,SV

gmt coast -R"Central America" -Gred -B -png mapa

@Esteban82
Copy link
Member

So, this seems to work fine.

Should I approve the PR?
Where should I write the list for dcw-collections.txt?
What about other regions which do not include countries like seas?

Also, I was thinking that maybe we could add the full name for countries (e.g. -RJapan).

@PaulWessel
Copy link
Member Author

Should I approve the PR?

Not yet. We will wait until the dcw-collections.txt have been reviewed by the team.

Where should I write the list for dcw-collections.txt?

That file should be added to the dcw-gmt repo where the country and state lists are.

What about other regions which do not include countries like seas?

Those regions are more like named region with a corresponding -Rw/e/s/n string and does not have anything to do with DCW per se. Not sure, but it would be a different file, such as gmt-regions.txt with records like

# Named oceans
w/e/s/n SRG Sargasso Ocean
w/e/s/n NATL North Atlantic Ocean
etc.

But maybe we do add it to DCW so that -E+n can list them as well - they are just different in that it is just a shorthand for a w/e/s/n setting, but the padding via +r|R still applies to those regions. So make a separate dcw-regions.txt file for dcw-gmt repo instead.

Also, I was thinking that maybe we could add the full name for countries (e.g. -RJapan).

OK, those names are already in the DCW tables so this is a software update in GMT only,

@anbj
Copy link
Contributor

anbj commented Nov 29, 2021

Just a thought: this feature is now hard linked to DCW, but it need not be. The feature of defining areas of interests is very handy, regardless of DCW. DCW makes it super convenient in that you can supply a bunch of country codes. It should also be possible to being able to define an -R

Like:

0/360/55/90 IBCAO International bathy.....

Edit: And I see Paul has commented on this in #6064 (comment).

@anbj
Copy link
Contributor

anbj commented Nov 29, 2021

Minor comment: Ability to separate blocks with an empty line - pure cosmetical/convenience. Especially nice if it's possible to define -R with no country codes (to be able to easilty read the file):

$ cat .gmt/geography/dcw/dcw-collections.txt 
tag: SCA Scandinavia
NO,SE,DK

tag: NOR Fullnametest
NO
$ gmt pscoast -E+n
pscoast [ERROR]: Collection file /home/anbj/.gmt/geography/dcw/dcw-collections.txt is not in correct format - exit
-R0/0/0/0

Alright - remote empty line and check again:

$ cat .gmt/geography/dcw/dcw-collections.txt 
tag: SCA Scandinavia
NO,SE,DK
tag: NOR Fullnametest
NO

The tag does not seem to be correctly read for the second block ("Fullnametest"). Both turn up as SCA:

$ gmt pscoast -E+n
Scandinavia	SCA	NO,SE,DK
Fullnametest	SCA	NO

@anbj
Copy link
Contributor

anbj commented Nov 29, 2021

How is the user supposed to add entries? Edit dcw-collections.txt directly? How does gmt handle this? I guess the file is checked against a hash?

@PaulWessel
Copy link
Member Author

The dcw-collection is read only for users. They instead edit a dcw-groups.txt file in their ./gmt directory

@anbj
Copy link
Contributor

anbj commented Nov 29, 2021

Ok, so the dcw-collection is made by the devs with a set of assumed relevant/interesting areas.

@Esteban82
Copy link
Member

Esteban82 commented Nov 29, 2021

Ok, so the dcw-collection is made by the devs with a set of assumed relevant/interesting areas.

Yes, that is my idea. The user then, can modified or add the records on that file.

About the list, I think we should follow some guidelines. I am thinking on:

  1. Collections of countries that are "stable" on time. So they should be based on cultural, historical and geographic aspects and maybe not in political or economical (e.g. Eurozone) ones. The later could change with time and we should update the list.
  2. We should use international and well-known regions. Maybe use collections define by an organism like U.N.?
  3. Exclude countries that are partially identified for a collection. For example, Mexico sometimes is defined as part of Central America and sometimes not. I think we should exclude because we always could do -R"Central America",MX

Some doubts:

  1. Should we limit the number of countries per collection? i.e. only define collections which has at least 4countries? The users can easily handle with 3 countries. Not sure if the limit should be 4. Maybe.
  2. We should limit the extend of collections? Edit: If the list is too long, maybe we should define a way to order the list.

@PaulWessel
Copy link
Member Author

Just so we are clear, there are for now two separate files: dcw-collections.txt comes with the DCW installation and is a list of things we developers wishes for all to have access to. Then, users can extend that reach by adding their own dci-groups.txt file to ~/.gmt. We can discuss if both files should be called dcw-collections.txt which may be more consistent.

There seems also to be a need for a list of named regions that are shorthands to specific -Rw/e/s/n settings. We can worry later if those should also go into the same file or a separate file. I can code it either way. But likewise, we should supply some basic well known cases in the DCW repo distribution and then users can create their own extensions to that.

@Esteban82
Copy link
Member

Here there is the sub-regions use by the United Nations:

https://en.wikipedia.org/wiki/United_Nations_geoscheme.

@PaulWessel
Copy link
Member Author

Here there is the sub-regions use by the United Nations:

https://en.wikipedia.org/wiki/United_Nations_geoscheme.

Yes, that list plus your 9-10 oceanic regions would be a good set of named regions for DCW to provide. Then users can add odd regions are they see fit.

So, since we don't want the users to deal with too many files, perhaps both the current tag and the naemd region should be in a single file with mix and match. Perhaps this is the format of dcw-collections.txt:

# Central America
tag: CAM Central America
list: BZ,CR,HN,GT,NI,PA,SV
# The Sargasso sea
tag: SRG Sargasso Sea
region: -88/-66/12/35
...

That means we have ~30 named entries supplied via DCW and the E+n will list them. I can make the code changes later today, including skipping blank lines as per @anbj.

@PaulWessel
Copy link
Member Author

Update: Here are some changes:

  1. The user file and the DCW system file now have the same name dcw-collections.txt
  2. The file now supports both the collection lists and name region wesn as suggsted above
  3. I fixed the bug that report the same code for all collections
  4. I added some documentation to the coast man page
  5. I tested this with a dummy north sea region and combinations like -RNO,NSEA worked fine.
  6. The name regions do not correspond to any data so you cannot use -RNorthSea to extract data. This may lead to a crash - have not checked yet.

@Esteban82
Copy link
Member

Yes, that list plus your 9-10 oceanic regions would be a good set of named regions for DCW to provide. Then users can add odd regions are they see fit.

I see that the UN region are follow the below code where each region is defined by 3 numbers.
https://en.wikipedia.org/wiki/UN_M49

So we get this for example:

# Central America
tag: 029 Central America
list: BZ,CR,HN,GT,NI,PA,SV

Also, there are some major sub-regions. For example sub-saharan africa which includes four sub-regions (western africa, central africa, southern africa, eastern africa). Another major sub-region is Latin American and the Caribbean. I am not including them,

@PaulWessel
Copy link
Member Author

Do we want to use UN029 instead of 029? I worry that giving an integer will cause trouble with the -R parsing. Currently it checks for letters.

@Esteban82
Copy link
Member

Yes, I will add it. I get an error for -R (but not for -E).

@anbj
Copy link
Contributor

anbj commented Nov 30, 2021

  1. What about adding a header when listing groups/regions? Something like:
$ gmt pscoast -E+n
Description/Name              Tag          Country code(s)/region                 <---------
FrancoItalic Union	FRIT	FR,IT
Sargasso Sea	SARG	70W/40W/20N/35N
  1. Formatting output from gmt pscoast -E+n should ideally line up nicely, but this may be difficult due to variable length of the different fields (especially the "Description/Name"). E.g. a tag including two country codes vs. a tag including 10 country codes. Of these, the "Description/Name" column may potentially be the messiest - output that as the 3. column?

  2. It seems that country codes in general are case sensitive (at least the first letter - see below). Should they be? If it required, it should be noted in the man-pages. Case is also important for this new feature:

If I create a tag with lowercase:

# Stay away from those eels!
tag: sarg Sargasso Sea
region:  70W/40W/20N/35N
$ gmt pscoast -Esarg
pscoast [ERROR]: Could not parse sarg into Geographical, Cartesian, or Temporal coordinates!
pscoast [ERROR]: Option -R parsing failure. Correct syntax:
[...]

Change the tag's first letter to uppercase (but don't change tag in dcw-collections.txt). Note different warning compared to the example above:

$ gmt pscoast -ESarg
pscoast [WARNING]: No country code matching Sarg (skipped)
pscoast [WARNING]: Column selected for latitude-formatting has values that exceed +/- 90; set to NaN
pscoast [WARNING]: Column selected for latitude-formatting has values that exceed +/- 90; set to NaN
-R0/0/NaN/NaN

Change tag (in dcw-collections.txt) as well:

# Stay away from those eels!
tag: Sarg Sargasso Sea
region:  70W/40W/20N/35N

And it works fine:

 gmt pscoast -ESarg
-R-70/-40/20/35

So seems that it is important that the first letter is uppercase. If you change one of the other letters to uppercase you get trouble:

# Stay away from those eels!
tag: sarG Sargasso Sea
region:  70W/40W/20N/35N
$ gmt pscoast -EsarG
pscoast [ERROR]: Could not parse sarG into Geographical, Cartesian, or Temporal coordinates!
pscoast [ERROR]: Option -R parsing failure. Correct syntax:
[...]

Starting to nitpick now.

  1. Use with -R seems to work:
tag: NOS Norwegian Sea
region: -25/20/60/75

Both

$ gmt pscoast -R"Norwegian Sea" -M -W |head
> Shore Bin # 37, Level 1
> Shore Bin # 37, Level 1
> Shore Bin # 37, Level 1
> Shore Bin # 37, Level 1
19.0000762951	74.3678950179
19.2561226825	74.4333562219
[...]

and

gmt pscoast -R"Norwegian Sea" -JM5c -W -pdf test

runs fine (but same issue with letter case as descibed above).

@PaulWessel
Copy link
Member Author

Error fixed, @Esteban82

@Esteban82
Copy link
Member

Error fixed, @Esteban82

Thanks. Now there is the issue that anbj reported. With gmt pscoast -ENO+n I get the collections which include NO and all the regions define by a bounding box (seas, oceans, continents, islands, etc.).

Another issue is that the list follow the original order of the dcw-collections.txt which is not alphabetically and can be confusing for the user.

@Esteban82
Copy link
Member

If a run gmt coast -REurope -W -B -png map I get the map that correspond to -R=EU. I think that I should get the bounding box region define in dcw-collections.txt. The same happened with Africa, Asia, North America and South America.

BTW, I noticed that some regions have the same name that collection of countries.

map

@PaulWessel
Copy link
Member Author

Try this update.

@maxrjones maxrjones added the add-changelog Add PR to the changelog label Jan 13, 2022
@Esteban82
Copy link
Member

Try this update.

It works. Now I have to update dcw-collections.txt

@PaulWessel
Copy link
Member Author

OK, so I can merge this branch then?

@Esteban82
Copy link
Member

OK, so I can merge this branch then?

I think that anbj comment wasn't fix.

Shortly, If I run gmt pscoast -ENO+n I should get only the collections with Norway. But I get also all the bounding box regions.

@PaulWessel
Copy link
Member Author

Ok, after dinner

@PaulWessel
Copy link
Member Author

I think I have fixed @anbj's problem, perhaps @Esteban82 can check - I am off for a few hours on an errand.

@Esteban82
Copy link
Member

I think I have fixed @anbj's problem, perhaps @Esteban82 can check - I am off for a few hours on an errand.

Great. Now it is fixed.

So the code basically search the string in Codes and in names, right?

BTW I just noticed that I can make this which is good.

gmt pscoast -EIsland+n
# TAG	Name		Codes|Region
NGNI	New Guinea Island	130.93/150.877/-10.705/-0.339
BRNI	Borneo Island	108.845/119.275/-4.185/7.035
BFFI	Baffin Island	-89.543/-61.263/61.863/73.737
SMTI	Sumatra Island	95.195/106.087/-5.945/5.661
HNSI	Honshu Island	130.862/142.07/33.435/41.546
VCTI	Victoria Island	-119.123/-100.846/68.461/73.378
GBRI	Great Britain Island	-6.231/1.766/49.957/58.673
ELLI	Ellesmere Island	-91.912/-61.101/76.131/83.213
SLWI	Sulawesi Island	118.753/125.252/-5.707/1.756
SNZI	South Island	166.425/174.319/-46.679/-40.499
JAVI	Java Island	105.206/114.603/-8.782/-5.875
NNZI	North Island	172.644/178.553/-41.615/-34.396
...

@PaulWessel
Copy link
Member Author

Given 2.1.0 has been released I think it is OK to approve and merge this branch. Stuff seems to work, e.g.

gmt pscoast -E"Inner Seas of the West Coast of Scotland"
-R-8.2827/-4.4275/54.3458/58.6227

Any remaining issues, @Esteban82 ?

@PaulWessel
Copy link
Member Author

Sorry, missed seeing the approval. Merging

@PaulWessel PaulWessel merged commit 0feb95e into master Jan 16, 2022
@PaulWessel PaulWessel deleted the dcw-collections branch January 16, 2022 00:01
@anbj
Copy link
Contributor

anbj commented Jan 18, 2022

Nitpicking:

If you define a non-existing code, and at least one existing code, you get a nice warning.

$ gmt pscoast -R'i do not exist',NO -JM15c -pdf test -W
coast [WARNING]: No country code matching i do not exist (skipped)

If you only define a single non-existing code, you will get a lon/lat- and projection errors, in addition to the warning.
Maybe check if only one input code is given, and if it does not exist, give an (one) error regarding this and stop?

$ gmt pscoast -R'i do not exist' -JM15c -pdf test -W
coast [WARNING]: No country code matching i do not exist (skipped)
coast [ERROR]: South is outside -90 to +90 degree range
coast [ERROR]: General map projection error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add-changelog Add PR to the changelog enhancement Improving an existing feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create list of oceans, seas and other regions.

6 participants