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

Plotting multiple shapefiles fail #1280

Closed
Karichoud opened this issue Oct 2, 2023 · 1 comment
Closed

Plotting multiple shapefiles fail #1280

Karichoud opened this issue Oct 2, 2023 · 1 comment

Comments

@Karichoud
Copy link

Hi,

I am relatively new to Julia in general and GMT.jl in particular. I am facing a bug I am unable to correct. Basically, I want to plot on the same figure the divides of drainage basins defined by shapefiles (.shp). The first one is correctly plotted but the second one creates an error. Here is the code I tested:

using GMT
subcatch_1 = gmtread(path_Bas_shp[1], no_islands=true);
plot(subcatch_1, pen=(:thinnest, :black), region=(-82, -40, -24, 8), proj=(name=:eqdc, center=[-66 -6], parallels=[-5 -12]), show=true);
subcatch_2 = gmtread(path_Bas_shp[2], no_islands=true);
plot!(subcatch_2, pen=(:thinnest, :black), show=true);

after the correct plot of the first basin, I get this message:

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Error: /undefined in A
Operand stack:
0
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1974 1 3 %oparray_pop 1973 1 3 %oparray_pop 1961 1 3 %oparray_pop 1817 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:767/1123(ro)(G)-- --dict:0/20(G)-- --dict:75/200(L)--
Current allocation mode is local
Last OS error: No such file or directory
Current file position is 40064

psconvert [ERROR]: System call ['/home/ubuntu/.julia/artifacts/4883a6685d86b068da934537a444a6d170d71730/bin/gs' -q -dNOSAFER -dNOPAUSE -dBATCH -sDEVICE=bbox -DPSL_no_pagefill -dMaxBitmap=2147483647 -dUseFastColor=true '/tmp/GMTjl_ubuntu.ps' 2> './psconvert_73850c.bb'] returned error 256.

Something went wrong when calling the module. GMT error number = 79

Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] gmt(::String)
@ GMT ~/.julia/packages/GMT/Mxc9g/src/gmt_main.jl:161
[3] showfig(d::Dict{Symbol, Any}, fname_ps::String, fname_ext::String, opt_T::String, K::Bool, fname::String)
@ GMT ~/.julia/packages/GMT/Mxc9g/src/common_options.jl:3929
[4] finish_PS_module(::Dict{Symbol, Any}, ::Vector{String}, ::String, ::Bool, ::Bool, ::Bool, ::GMTdataset{Float64, 2}, ::Vararg{Any})
@ GMT ~/.julia/packages/GMT/Mxc9g/src/common_options.jl:4214
[5] common_plot_xyz(::String, ::GMTdataset{Float64, 2}, ::String, ::Bool, ::Bool, ::Pair{Symbol, Any}, ::Vararg{Pair{Symbol, Any}})
@ GMT ~/.julia/packages/GMT/Mxc9g/src/psxy.jl:285
[6] plot(arg1::GMTdataset{Float64, 2}; first::Bool, kw::Base.Pairs{Symbol, Any, Tuple{Symbol, Symbol}, NamedTuple{(:pen, :show), Tuple{Tuple{Symbol, Symbol}, Bool}}})
@ GMT ~/.julia/packages/GMT/Mxc9g/src/plot.jl:122
[7] plot
@ ~/.julia/packages/GMT/Mxc9g/src/plot.jl:101 [inlined]
[8] #plot!#447
@ ~/.julia/packages/GMT/Mxc9g/src/plot.jl:124 [inlined]
[9] top-level scope
@ In[7]:4
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

I have exactly the same behaviour whether I use lines, scatter or plot. It is not a problem with the second shapefile because if I plot again the first one, I have exactly the same error message. My issue looks similar to this one: https://forum.generic-mapping-tools.org/t/failed-to-plot-large-multiple-polygon-vector-shp-file-in-pygmt/3064 but I have tested different line width and the output is always the same. I suspect that the figure is closed after the first contour is plotted and that the problem is in common_options.jl.
I would be very grateful for any advice and help.

@joa-quim
Copy link
Member

joa-quim commented Oct 2, 2023

When you use the show option that finish the figure and shows it. You should only do that in the last command, but you are using it in both plot commands

subcatch_1 = gmtread(path_Bas_shp[1], no_islands=true);
plot(subcatch_1, pen=(:thinnest, :black), region=(-82, -40, -24, 8),
       proj=(name=:eqdc, center=[-66 -6], parallels=[-5 -12]), show=true);              # DON'T USE show HERE
subcatch_2 = gmtread(path_Bas_shp[2], no_islands=true);
plot!(subcatch_2, pen=(:thinnest, :black), show=true);
```

@joa-quim joa-quim closed this as completed Oct 5, 2023
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