Skip to content
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
8 changes: 4 additions & 4 deletions src/GMT.jl
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ export
rose!, sample1d, scatter, scatter!, scatter3, scatter3!, solar, solar!, spectrum1d, sphdistance, sphinterpolate,
sphtriangulate, surface, ternary, ternary!, text, text!, text_record, trend1d, trend2d, triangulate, gmtsplit,
decorated, vector_attrib, wiggle, wiggle!, xyz2grd, gmtbegin, gmtend, gmthelp, subplot, gmtfig, inset, showfig,
earthtide, gravfft, gmtgravmag3d, gravmag3d, grdgravmag3d, gravprisms, grdseamount, parkermag, parkergrav,
earthtide, gmt2grd, gravfft, gmtgravmag3d, gravmag3d, grdgravmag3d, gravprisms, grdseamount, parkermag, parkergrav,
pscoupe, pscoupe!, coupe, coupe!, psmeca, psmeca!, meca, meca!, psvelo, psvelo!, velo, velo!, gmtisf, getbyattrib,
inpolygon, inwhichpolygon, pcolor, pcolor!, triplot, triplot!, trisurf, trisurf!, grdrotater, imagesc, upGMT, boxes,
stereonet, stereonet!,
Expand All @@ -162,8 +162,8 @@ export
importPROJ4, importWKT, importEPSG, gdalinfo, gdalwarp, gdaldem, gdaltranslate, gdalgrid, gdalvectortranslate,
ogr2ogr, gdalrasterize, gdalbuildvrt, readgeom, readraster, setgeotransform!, setnodata!, setproj!, destroy,
delaunay, dither, buffer, centroid, intersection, intersects, polyunion, overlaps, fromWKT, fillnodata!, fillnodata,
concavehull, convexhull, difference, symdifference, distance, geodesicarea, geomarea, pointalongline, polygonize, simplify,
boundary, crosses, disjoint, envelope, envelope3d, equals, touches, uniqueind, within,
concavehull, convexhull, difference, symdifference, distance, geodesicarea, geomarea, geomlength, pointalongline,
polygonize, simplify, boundary, crosses, disjoint, envelope, envelope3d, equals, touches, within,

wkbUnknown, wkbPoint, wkbPointZ, wkbLineString, wkbLineStringZ, wkbPolygon, wkbPolygonZM, wkbMultiPoint, wkbMultiPointZ,
wkbMultiLineString, wkbMultiPolygon, wkbGeometryCollection, wkbPoint25D, wkbLineString25D, wkbPolygon25D, wkbMultiPoint25D,
Expand Down Expand Up @@ -195,7 +195,7 @@ export

findpeaks, makeDCWs, mksymbol, circfit,

gunique, sortslicesperm,
gunique, uniqueind, sortslicesperm,
hampel, hampel!, lowess, whittaker,

Ginnerjoin, Gouterjoin, Gleftjoin, Grightjoin, Gcrossjoin, Gsemijoin, Gantijoin, spatialjoin, groupby, stats,
Expand Down
14 changes: 10 additions & 4 deletions src/gdal_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,10 @@ function gd2gmt(dataset::Gdal.AbstractDataset)
while ((feature = Gdal.nextfeature(layer)) !== nothing)
n = Gdal.nfield(feature)
attrib = DictSvS()
[attrib[Gdal.getname(Gdal.getfielddefn(feature, i))] = string(Gdal.getfield(feature, i)) for i = 0:n-1]
#[attrib[Gdal.getname(Gdal.getfielddefn(feature, i))] = string(Gdal.getfield(feature, i)) for i = 0:n-1]
for i = 0:n-1
attrib[Gdal.getname(Gdal.getfielddefn(feature, i))] = string(Gdal.getfield(feature, i))
end

for j = 0:Gdal.ngeom(feature)-1
geom = Gdal.getgeom(feature, j)
Expand Down Expand Up @@ -757,15 +760,18 @@ function gmt2gd(D::Vector{<:GMTdataset}; save::String="", geometry::String="")
for k = 1:length(D)
x,y,z = helper_gmt2gd_xyz(D[k], n_cols)
if (n_cols == 2)
[Gdal.addgeom!(geom, Gdal.createpoint(x[n], y[n])) for n = 1:lastindex(x)]
#[Gdal.addgeom!(geom, Gdal.createpoint(x[n], y[n])) for n = 1:lastindex(x)]
for n = 1:lastindex(x) Gdal.addgeom!(geom, Gdal.createpoint(x[n], y[n])) end
else
[Gdal.addgeom!(geom, Gdal.createpoint(x[n], y[n], z[n])) for n = 1:lastindex(x)]
#[Gdal.addgeom!(geom, Gdal.createpoint(x[n], y[n], z[n])) for n = 1:lastindex(x)]
for n = 1:lastindex(x) Gdal.addgeom!(geom, Gdal.createpoint(x[n], y[n], z[n])) end
end
end
elseif (D[1].geom == wkbMultiPointZ || D[1].geom == Gdal.wkbMultiPoint25D)
for k = 1:length(D)
x,y,z = helper_gmt2gd_xyz(D[k], n_cols)
[Gdal.addgeom!(geom, Gdal.createpoint(x[n], y[n], z[n])) for n = 1:lastindex(x)]
#[Gdal.addgeom!(geom, Gdal.createpoint(x[n], y[n], z[n])) for n = 1:lastindex(x)]
for n = 1:lastindex(x) Gdal.addgeom!(geom, Gdal.createpoint(x[n], y[n], z[n])) end
end
else
x,y,z = helper_gmt2gd_xyz(D[1], n_cols)
Expand Down
12 changes: 7 additions & 5 deletions src/grdview.jl
Original file line number Diff line number Diff line change
Expand Up @@ -119,16 +119,18 @@ end
function parse_G_grdview(d::Dict, symbs::Array{<:Symbol}, cmd0::String, cmd::String, arg1, arg2, arg3, arg4, arg5)
(SHOW_KWARGS[]) && return print_kwarg_opts(symbs, "GMTgrid | Tuple | String"), arg1, arg2, arg3, arg4, arg5
if ((val = find_in_dict(d, symbs)[1]) !== nothing)

function intern!(cmd, val, arg1, arg2, arg3, arg4)
opt = isa(val, GMTgrid) ? 'G' : 'z' # 'z' is the fake option that works as a backdoor for images
cmd, N_used = put_in_slot(cmd, opt, arg1, arg2, arg3, arg4)
if (N_used == 1) arg1 = val
elseif (N_used == 2) arg2 = val
elseif (N_used == 3) arg3 = val
elseif (N_used == 4) arg4 = val
cmd, _N_used = put_in_slot(cmd, opt, arg1, arg2, arg3, arg4)
if (_N_used == 1) arg1 = val
elseif (_N_used == 2) arg2 = val
elseif (_N_used == 3) arg3 = val
elseif (_N_used == 4) arg4 = val
end
return cmd, arg1, arg2, arg3, arg4
end

if (isa(val, String) || isa(val, GMTimage))
val_str::String = isa(val, String) ? val : ""
val_I::GMTimage = (val_str == "") ? val : GMTimage()
Expand Down
9 changes: 6 additions & 3 deletions src/pcolor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,19 @@ function pcolor(X_::VMr, Y_::VMr, C::Union{Nothing, AbstractMatrix{<:Real}}, fir
if (isvector(X) && gridreg) # Expand X,Y to make them pix reg
X,Y = copy(X_), copy(Y_)
xinc, yinc = X[2]-X[1], Y[2]-Y[1]; xinc2, yinc2 = xinc/2, yinc/2
[X[k] -= xinc2 for k = 1:numel(X)]; append!(X, X[end]+xinc)
[Y[k] -= yinc2 for k = 1:numel(Y)]; append!(Y, Y[end]+yinc)
for k = 1:numel(X)
X[k] -= xinc2; Y[k] -= yinc2
end
append!(X, X[end]+xinc); append!(Y, Y[end]+yinc)
end

D, k = Vector{GMTdataset{Float64,2}}(undef, length(C)), 0
if (isvector(X))
for col = 1:length(X)-1, row = 1:length(Y)-1 # Gdal.wkbPolygon = 3
if (k == 0)
D[k+=1] = mat2ds([X[col] Y[row]; X[col] Y[row+1]; X[col+1] Y[row+1]; X[col+1] Y[row]; X[col] Y[row]]; geom=3, d...)
else D[k+=1] = mat2ds([X[col] Y[row]; X[col] Y[row+1]; X[col+1] Y[row+1]; X[col+1] Y[row]; X[col] Y[row]]; geom=3)
else
D[k+=1] = mat2ds([X[col] Y[row]; X[col] Y[row+1]; X[col+1] Y[row+1]; X[col+1] Y[row]; X[col] Y[row]]; geom=3)
end
end
D[1].ds_bbox = [X[1], X[end], Y[1], Y[end]]
Expand Down
4 changes: 2 additions & 2 deletions src/plot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1717,7 +1717,7 @@ function parse_B4ternary!(d::Dict, first::Bool=true)
opt_Bs = split(opt_B) # This drops the leading ' '
x::String = (opt_Bs[1][3] == 'p') ? opt_Bs[1][4:end] : opt_Bs[1][3:end]
d[:B] = " -Ba$(x)+l" * string(val[1])::String * " -Bb$(x)+l" * string(val[2])::String * " -Bc$(x)+l" * string(val[3])::String
[d[:B] *= " " * opt_Bs[k] for k = 2:numel(opt_Bs)] # Append the remains, if any.
for k = 2:numel(opt_Bs) d[:B] *= " " * opt_Bs[k] end # Append the remains, if any.
else # Ui, try to parse a string like this: " -Bpag8+u\" %\" -Ba+la -Bb+lb -Bc+lc"
(!first && opt_B == " -Bafg") && return # Do not use the default -B on overlays.
opt_Bs = split(opt_B, " -B")[2:end] # 2:end because surprisingly the first is = ""
Expand All @@ -1727,7 +1727,7 @@ function parse_B4ternary!(d::Dict, first::Bool=true)
else
x = opt_Bs[1][2:end]
d[:B] = " -Ba$(x)" * opt_Bs[2][2:end] * " -Bb$(x)" * opt_Bs[3][2:end] * " -Bc$(x)" * opt_Bs[4][2:end]
[d[:B] *= " -B" * opt_Bs[k] for k = 5:numel(opt_Bs)] # Append the remains, if any.
for k = 5:numel(opt_Bs) d[:B] *= " -B" * opt_Bs[k] end # Append the remains, if any.
end
end
end
Expand Down
24 changes: 15 additions & 9 deletions src/sample1d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,20 @@ function sample1d_helper(cmd0::String, arg1, d::Dict{Symbol,Any})
tmp = tempname() * ".dat"
cmd = cmd * opt_g * " > " * tmp
gmt(cmd)
r = gmtread(tmp)
o = gmtread(tmp)
rm(tmp); (input_tmp != "") && rm(input_tmp)
if (have_nonans) # Remove NaNs if requested
if isa(r, GMTdataset)
indNaN = isnan.(view(r.data, :, 2))
any(indNaN) && (r = mat2ds(r.data, (.!indNaN, :)))
if isa(o, GMTdataset)
indNaN = isnan.(view(o.data, :, 2))
any(indNaN) && (o = mat2ds(o.data, (.!indNaN, :)))
else
for k = 1:numel(r)
indNaN = isnan.(view(r[k].data, :, 2))
any(indNaN) && (r[k] = mat2ds(r[k], (.!indNaN, :)))
for k = 1:numel(o)
indNaN = isnan.(view(o[k].data, :, 2))
any(indNaN) && (o[k] = mat2ds(o[k], (.!indNaN, :)))
end
end
end
return r
return o
end

# Tricky this one. If we use defaults, sample1d will not interpolate through NaNs. Need to use --IO_NAN_RECORDS=skip
Expand Down Expand Up @@ -164,7 +164,13 @@ function sample1d_helper(cmd0::String, arg1, d::Dict{Symbol,Any})
end
colnames = isa(arg1, GMTdataset) ? arg1.colnames : arg1[1].colnames
have_cumdist && append!(colnames, ["cumdist"])
isa(arg1, GMTdataset) ? (r.attrib = arg1.attrib) : [r[k].attrib = arg1[1].attrib for k = 1:numel(r)] # Keep the attribs
if (isa(arg1, GMTdataset))
r.attrib = arg1.attrib # Keep the attribs
else
for k = 1:numel(r)
r[k].attrib = arg1[1].attrib
end
end
else # Input was a file name
nc = isa(r, GMTdataset) ? size(r, 2) : size(r[1], 2)
colnames = [@sprintf("Z%d", k) for k = 1:nc]
Expand Down
2 changes: 1 addition & 1 deletion src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@ end

# ------------------------------------------------------------------------------------------------------
"""
getattribs(D::GDtype)::Vector{String}
att = getattribs(D::GDtype) -> Vector{String}

Extract attribute keys from a GMT data object as a vector of strings.

Expand Down
Loading