Skip to content

Figure.coast: No output of "+l|L" of "dcw" parameter ("E") when using an IDE #2646

Open

Description

@yvonnefroehlich

Description of the problem

First mentioned in #2428 (comment).

In the docstring for the dcw parameter of pygmt.Figure.coast we say:

Append +l|+L to =continent to only list countries in that continent; repeat if more than one continent is requested.

I tried this, but so far I am not sure how it should work. I only get an output when running the python script or code directly in a terminal. When using an IDE (e.g., Spyder, JupyterLab) there is no output neither in the console nor in the terminal.
Further, this part of the docstring is not precise, as +l gives the codes for the countries, but +L gives the codes for the states/territories.

Minimal Complete Verifiable Example

import pygmt

fig = pygmt.Figure()
fig.coast(dcw="=NA+l")
fig.coast(dcw="=NA+L")

Full error message

No error message occurs. 
No output occurs when running the code within an IDE (e.g., Spyder, JupyterLab).

System information

PyGMT information:
  version: v0.9.1.dev132
System information:
  python: 3.11.4 | packaged by conda-forge | (main, Jun 10 2023, 17:59:51) [MSC v.1935 64 bit (AMD64)]
  executable: C:\ProgramData\Anaconda3\envs\pygmt_env_dev\python.exe
  machine: Windows-10-10.0.19045-SP0
Dependency information:
  numpy: 1.24.3
  pandas: 2.0.2
  xarray: 2023.1.1.dev17
  netCDF4: 1.6.2
  packaging: 23.1
  contextily: 1.3.0
  geopandas: 0.13.2
  IPython: 8.14.0
  rioxarray: 0.14.1
  ghostscript: 9.54.0
GMT library information:
  binary version: 6.4.0
  cores: 4
  grid layout: rows
  image layout: 
  library path: C:/ProgramData/Anaconda3/envs/pygmt_env_dev/Library/bin/gmt.dll
  padding: 2
  plugin dir: C:/ProgramData/Anaconda3/envs/pygmt_env_dev/Library/bin/gmt_plugins
  share dir: C:/Program Files (x86)/gmt6/share
  version: 6.4.0

Activity

  1. added
    bug
    question
    on Aug 27, 2023
  2. added
    feature request
    and removed
    bug
    question
    on Nov 26, 2023
  3. seisman commented on Nov 27, 2023

    @seisman
    Member

    Here are some quick ideas about my expected functionality for the dcw data.

    >>> from pygmt import dcw
    
    >>> dcw.path 
    /path/to/gmt/share/dcw  # path to the dcw directory
    >>> dcw.version
    2.1.2
    >>> north_america = dcw(continent="NA") # A DCW_Continent object
    >>> print(north_america) # print something about the North America continent
    north_america.code = "=NA"  # GMT's internal code
    north_america.countries = ["AO", "BF", ...]  # list of country codes
    # Or maybe it should be dict of DCW_Country object, then we can have the following syntax:
    >>> north_america["US"]  # A DCW_Country object
    
    >>> north_america.to_file("na.txt")  # save data to a file
    >>> gdf = north_america.to_geopandas() # save data into a geopandas object
    >>> north_america.region  # region: [xmin, xmax, ymin, ymax]
    
    # Here is another way to have a DCW_Country object
    >>> usa = dcw(country="US")  # returns a DCW_Country object
    >>> usa.code
    "US"
    >>> usa.to_file("usa.txt")
    >>> gdf = usa.to_geopandas()
    >>> usa.region
    [xxx, xxx, xxx, xxx]
    >>> usa.states   # List of DCW_State object
    ["CI", "MI", ...]
    >>> usa["CI"]  # A DCW_State object
    
    # Here is another way to have a DCW_State object
    >>> california = dcw(country="US", state="CI")
    >>> california.code
    "US.CI"
    >>> california.to_file("ci.txt")
    >>> california.to_geopandas()
    >>> california.region
    [xxx, xxxx, xxx, xxx]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions