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

When reading images reshape the incoming row major array like in gdalread. #1623

Merged
merged 3 commits into from
Dec 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/gmt_main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,8 @@ function get_image(API::Ptr{Nothing}, object)::GMTimage
if (layout != "" && layout[1] == 'I') # The special layout for using this image in Images.jl
o = (nz == 1) ? (ny, nx) : (nz, ny, nx)
else
o = (nz == 1) ? (ny, nx) : (ny, nx, nz)
#o = (nz == 1) ? (ny, nx) : (ny, nx, nz)
o = (nz == 1) ? (nx, ny) : (nx, ny, nz)
isBRP = startswith(layout, "BRP") || startswith(layout, "TRP")
(nz == 1 && isBRP) && (layout = "BRPa") # For 1 layer "BRBa" and "BRPa" is actualy the same.
(!isBRP && nz > 1) && @warn("Only 'I' for Images.jl and 'BRP' MEM layouts are allowed.")
Expand Down
2 changes: 1 addition & 1 deletion src/psxy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1233,7 +1233,7 @@ function make_color_column(d::Dict, cmd::String, opt_i::String, len_cmd::Int, N_
end

# Filled polygons with -Z don't need extra col
((val = find_in_dict(d, [:G :fill], false)[1]) == "+z") && return cmd, arg1, nothing, N_args, false
((val = find_in_dict(d, [:G :fill], false)[1]) == "+z") && return cmd, arg1, arg2, N_args, false

n_rows, n_col = get_sizes(arg1) # Deal with the matrix, DS & Vec{DS} cases
#(isa(mz, Int) && mz <= n_col && mz == 3+is3D) && return cmd, arg1, nothing, N_args, false # zcolor column is already in place
Expand Down
18 changes: 10 additions & 8 deletions src/spatial_funs.jl
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
# ---------------------------------------------------------------------------------------------------
"""
zvals = polygonlevels(D::GDtype, ids::Vector{String}, vals::Vector{<:Real}; kw...) -> Vector{Float64}
or
zvals = polygonlevels(D::GDtype, ids::VecOrMat{String}, vals::Vector{<:Real}; kw...) -> Vector{Float64}

zvals = polygonlevels(D::GDtype, ids::Matrix{String}, vals::Vector{<:Real}; kw...) -> Vector{Float64}
Create a vector with `zvals` to use in `plot` and where length(zvals) == length(D)

Creates a vector with `zvals` to use in `plot` and where length(zvals) == length(D)
The elements of `zvals` are made up from the `vals`.

- `ids`: is a string Vector or Matrix with the ids (attribute names) of the GMTdataset D.
### Args
- `D`: The data in a vector of GMTdataset.
- `ids`: is a string Vector or Matrix with the ids (attribute names) of the GMTdataset `D`.
If a Matrix (2 columns only) then the `att` bellow must also have the two names (string vector
with two elements) that will be matched against the two elements of each line of `ids`.
The idea here is to match two conditions: `att[1] == ids[n,1] && att[2] == ids[n,2]`
- `vals`: is a vector with the numbers to be used in plot `level` to color the polygons.
- `attrib` or `att`: keyword to select which attribute to use when matching with contents of the `ids` strings.
- `nocase` or `insensitive`: a keyword from `kw`. Perform a case insensitive comparision between the contents of

### Kwargs
- `attrib` or `att`: Select which attribute to use when matching with contents of the `ids` strings.
- `nocase` or `insensitive`: Perform a case insensitive comparision between the contents of
`ids` and the attribute specified with `attrib`. Default compares as case sensistive.
- `repeat`: keyword to replicate the previously known value until it finds a new segment ID for the case
- `repeat`: Replicate the previously known value until it finds a new segment ID for the case
when a polygon have no attributes (may happen for the islands in a country).

Returns a Vector{Float64} with the same length as the number of segments in D. Its content are
Expand Down
Loading