Skip to content
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

Error using grdmask #745

Closed
amarux opened this issue Nov 4, 2021 · 3 comments
Closed

Error using grdmask #745

amarux opened this issue Nov 4, 2021 · 3 comments

Comments

@amarux
Copy link

amarux commented Nov 4, 2021

Hello!

I am testing the use of grdmask to find grid points inside the polygon defined below:

# @VGMT1.0 @GPOLYGON
# @R-104.342527492/-44.5264106724/6.59840161027/39.1723154376             
# @Je4326
# @Jp"+proj=longlat +datum=WGS84 +no_defs "
# @Jw"GEOGCS[\"GCS_WGS_1984\",DATUM[\"WGS_1984\",SPHEROID[\"WGS_84\",6378137,298.257223563]],PRIMEM[\"Greenwich\",0],UNIT[\"Degree\",0.017453292519943295],AUTHORITY[\"EPSG\",\"4326\"]]"
# @Nid
# @Tdouble
# FEATURE_DATA
>
# @D1
# @P
-73.1094285199206 6.59840161026737
-77.4631332251667 7.98653934237482
-78.4095907697854 8.93299688699353
-78.8512709572742 9.24848273519977
-79.9239228411754 9.05919122627603
-80.9965747250766 8.4913166995048
-81.5013520822066 8.4913166995048
-82.637101135749 8.80680254771104
-84.7193077339102 10.6997176369485
-86.2967369749414 13.4759931011634
-87.4324860284838 14.927228002912
-90.9659275283937 15.936782717172
-95.2565350639985 17.5773091278444
-98.6637822246259 18.9023496903106
-102.38651523346 22.6881798687855
-103.522264287002 26.9787874043903
-104.153235983414 31.5848807882014
-104.342527492338 38.2258578929427
-44.5264106724355 39.1723154375614
-45.2204795384892 6.80346741160142
-45.2204795384892 6.80346741160142
-73.1094285199206 6.59840161026737

To call grdmask I am using the following statement:

 grdmask(polygon_file, R=:"119.0/290.0/-2.0/31.0", I=:"1.0")

After this, the following error is showed:

grdmask [ERROR]: Option -n given more than once
grdmask [ERROR]: Option -n parsing failure. Correct syntax:
    -n[b|c|l|n][+a][+b<BC>][+c][+t<threshold>]
       Determine the grid interpolation mode.
       (b = B-spline, c = bicubic, l = bilinear, n = nearest-neighbor) [Default: bicubic].
       Append +a switch off antialiasing (except for l) [Default: on].
       Append +b<BC> to change boundary conditions.  <BC> can be either:
       g for geographic boundary conditions, or one or both of
       x for periodic boundary conditions on x,
       y for periodic boundary conditions on y.
       [Default: Natural conditions, unless grid is known to be geographic].
       Append +c to clip interpolated grid to input z-min/max [Default may exceed limits].
       Append +t<threshold> to change the minimum weight in vicinity of NaNs. A threshold of
       1.0 requires all nodes involved in interpolation to be non-NaN; 0.5 will interpolate
       about half way from a non-NaN to a NaN node [Default: 0.5].
grdmask [ERROR]: Offending option -n+a
ERROR: Something went wrong when calling the module. GMT error number = 72
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] gmt(cmd::String, args::Nothing)
   @ GMT ~/.julia/packages/GMT/TPV4a/src/gmt_main.jl:288
 [3] common_grd(d::Dict{Symbol, Any}, cmd::String, args::Nothing)
   @ GMT ~/.julia/packages/GMT/TPV4a/src/common_options.jl:3207
 [4] grdmask(cmd0::String, arg1::Nothing; kwargs::Base.Iterators.Pairs{Symbol, String, Tuple{Symbol, Symbol}, NamedTuple{(:R, :I), Tuple{String, String}}})
   @ GMT ~/.julia/packages/GMT/TPV4a/src/grdmask.jl:56
 [5] top-level scope
   @ none:1

Am I missing something?

Thanks in advance!

@joa-quim
Copy link
Member

joa-quim commented Nov 4, 2021

Hmm, we don't do R=:"119.0/290.0/-2.0/31.0", I=:"1.0", that is the : is to avoid the pairs of double quotes when possible. So it would be R="119.0/290.0/-2.0/31.0", I=1), but this is not the real cause of the error.
Apparently there is a bug in the grdmask implementation that does not recognize the input polygon as a file name. The solution so far is to read the polygon file in advance. E.g.

D = gmtread("polygon_file")
G = grdmask(D, R="119.0/290.0/-2.0/31.0", I="1.0");

@amarux
Copy link
Author

amarux commented Nov 5, 2021

Thank you for the clarification!
Your solution works very well!

Thanks again

@joa-quim
Copy link
Member

joa-quim commented Nov 5, 2021

And bug fixed in #746

@joa-quim joa-quim closed this as completed Nov 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants