Utility functions

append2fig(fname::String)

Move the file fname to the default name and location (GMTjl_tmp.ps in tmp). The fname should be a PS file that has NOT been closed. Posterior calls to plotting methods will append to this file. Useful when creating figures that use a common base map that may be heavy (slow) to compute.

blendimg!(color::GMTimage, shade::GMTimage; new=false)

Blend the RGB color GMTimage with the shade intensity image (normally obtained with gdaldem) The new argument determines if we return a new RGB image or update the color argument.

The blending method is the one explained in https://gis.stackexchange.com/questions/255537/merging-hillshade-dem-data-into-color-relief-single-geotiff-with-qgis-and-gdal/255574#255574

Returns

A GMT RGB Image

blendimg!(img1::GMTimage, img2::GMTimage; new=false, transparency=0.5)

Blend two 2D UInt8 or 2 RGB images using transparency.

  • transparency The default value, 0.5, gives equal weight to both images. 0.75 will make img weight 3/4 of the total sum, and so forth.

  • new If true returns a new GMTimage object, otherwise it cahnges the img content.

Returns

A GMT intensity Image

theta, rho = cart2pol(x, y; deg=false)

Transform Cartesian to polar coordinates. Angles are returned in radians by default. Use deg=true to return the angles in degrees. Input can be scalar, vectors or matrices.

az, elev, rho = cart2sph(x, y, z; deg=false)

Transform Cartesian coordinates to spherical. Angles are returned in radians by default. Use deg=true to return the angles in degrees. Input can be scalar, vectors or matrices.

colorzones!(shapes::Vector{GMTdataset}[, fun::Function]; img::GMTimage=nothing,
            url::AbstractString="", layer=0, pixelsize::Int=0, append::Bool=true)

Paint the polygons in the shapes with the average color that those polygons ocupy in the img image. When the shapes are plotted the resulting image looks like a choropleth map. Alternatively, instead of transmitting the img image one can provide a WMS URL, layer number and pixelsize to download images from the Web Map Server service, covering each one the bounding box of each of the shapes polygons. This option is much slower than passing the entire image at once but consumes much less memory. Important when the total area is large (think Russia size) because even at a moderately resultion it can imply downloading a huge file.

Parameters

  • shapes: A vector of GMTdataset containing the polygons to be painted. This container will be changed in the sense that the header field of each polygon (a GMTdataset) will be appended with the fill color (but see also the append option that controls how this change takes place.)

  • fun: By default the average color is obtained by taking the square root of the average of squares of each of the three (RGB) bands (or just one for grayscale images). Give the name of another function to replace this default. For example median will assign the color by computing the median of each component inside the polygon area in question.

  • img: the image from which the stats (fun) of each color for each polygon will be computed.

  • url: In case the img option is not used, pass the Web Map Server URL (see the wmsinfo and wmsread functions) from where the the images covering the BoundingBox of each polygon will be downloaded. Warning, this is a much slower method but potentially usefull when the images to download risk to be very big.

  • layer: When the url option is used this one becomes mandatory and represents the layer number or layer name of interest from those provided by the WMS service. That is, both of these forms are allowed: layer=3 or layer="Invented layer name"

  • pixelsize: Sets the requested cell size in meters [default]. Use a string appended with a 'd' (e.g. resolution="0.001d") if the resolution is given in degrees. This way works only when the layer is in geogs.

  • append: By default the color assignement to each of the polygons in the shapes vector is achieved by appending the fill color to the possibly existing header field. Running the colorzones command more than once keeps adding (now ignored, because only the first is used) colors. Setting append=false forces rewriting the header field at each run and hence the assigned color is always the one used (but the previous header is cleared out).

See also: rasterzones!

Returns

It does't return anything but the input shapes is modified.

Example

Read the 2020 Sentinel2 Earth color for Portugal at 100 m resolution. Load the administrative
regions and compute their median colors.

wms = wmsinfo("http://tiles.maps.eox.at/wms?");
img = wmsread(wms, layer=3, region=(-9.6,-6,36.9,42.2), pixelsize=100);
Pt = gmtread("C:/programs/compa_libs/covid19pt/extra/mapas/concelhos/concelhos.shp");
colorzones!(Pt, median, img=img);
imshow(Pt, proj=:guess)
C = cpt4dcw(codes::String, vals::Vector{<:Real}; kwargs...)

Create a categorical CPT to use with the output of coast(dcw=...) to make Choropleth maps.

  • codes is a comma separated string with two chars country codes (ex: "PT,ES,FR,IT")

  • vals a vector with same size as country codes, with the values used to colorize the countries

Optionally provide a CPT in the kwarg cmap=CPT with a range sufficient to transform the vals in colors. As an alternative to the above, provide a makecpt type range numeric vector to create a CPT. If none of these are provided a default CPT = makecpt(range=(0,255,1)) will be used.

crop(arg::GItype; kw...)

Crop a subregion of a grid (GMTgrid) or a image (GMTimage). The subregion is specified with the $limits$ or $region$ keyword; the specified range must not exceed the range of the input. This function differs from $grdcut$ in the sense that it doesn't call the GMT lib and works only on in-memory array (i.e., no disk files).

Returns

A grid or an image, depending on the input type, plus two 1x2 matrices with the indices of the cropped zone.

Example

G = GMT.peaks();
crop(G, region=(-2,2,-2,2))
slicecube(I::GMTimage, layer::Int)

Take a slice of a multylayer GMTimage. Return the result still as a GMTimage. layer is the z slice number.

slicecube(G::GMTgrid, slice; axis="z")

Extract a slice from a GMTgrid cube.

  • slice: If it is an Int it will return a GMTgrid corresponding to that layer. However, if slice is a float this is interpreted to mean: search that dimension (see the axis below) coordinates and find the closest layer that has coordinate = slice. If the slice value is not within 10% of the coordinate of closest layer, the returned layer is obtained by linear interpolation of the neighboring layers. For example, slice=2.5 on a cube were layers are one unit apart will interpolate between layers 2 and 3 where each layer weights 50% in the end result. NOTE: the return type is still a cube but with one layer only (and the corresponding axis coordinate).

  • axis: denotes the dimension being sliced. The default, "z", means the slices are taken from the vertical axis. axis="x" means slice along a column, and axis="y" slice along a row.

slicecube(GI::GItype; slice::Int=0, angle=0.0, axis="x", cmap=GMTcpt())

Take a slice of a GMTgrid or GMTimage in an oblique direction. Take the cube's layer slice and rotate it by angle degrees about the axis. This one can only be axis=:x or axis=:y. Depending on the data type of input a different output is produces. If GI is a GMTgrid, the output is 2 GMTgrids: one with z levels and the other with cube's z levels along that plane. On the other hand, if GI isa GMTimage the first output is similar to previus case but the second will be a GMTimage. In this case the cmap option may be used to assign a colortable to the image type.

The value at the slice point, P(x[i,j], y[i,j], z[i, j)), is the interpolated value of the two nearest voxels on the same vertical.

Example

Get the fourth layer of the multi-layered 'I' GMTimage object

I = slicecube(I, 4)
date2doy(date) -> Integer

Compute the Day-Of-Year (DOY) from date that can be a string or a Date/DateTime type. If ommited, returns today's DOY

delrows!(A::Matrix, rows::VecOrMat)

Delete the rows of Matrix A listed in the vector rows

doy2date(doy[, year]) -> Date

Compute the date from the Day-Of-Year doy. If year is ommited we take it to mean the current year. Both doy and year can be strings or integers.

gadm(country, subregions...; children=false, names=false, children_raw=false, reportlevels=false)

Returns a GMTdataset for the requested country, or country subregion(s)

  1. country: ISO 3166 Alpha 3 country code .

  2. subregions: Full official names in hierarchial order (provinces, districts, etc...). To know the names of all administrative children of parent, use the option names.

  3. children: When true, function returns all subregions of parent.

  4. children_raw: When true, function returns two variables -> parent, children, where children is a GDAL object E.g. when children is set to true and when querying just the country, second return parameter are the states/provinces. If children we return a Vector of GMTdataset with the polygons. If children_raw the second output is a GDAL object much like in GADM.jl (less the Tables.jl)

  5. names: Return a string vector with all children names.

  6. reportlevels: just report the number of administrative levels (including the country) and exit.

Examples

# data of India's borders
data = gadm("IND")

# uttar -> the limits of the Uttar Pradesh state
uttar = gadm("IND", "Uttar Pradesh")

# uttar -> limits of all districts of the  Uttar Pradesh state
uttar = gadm("IND", "Uttar Pradesh", children=true)

# Names of all states of India
gadm("IND", names=true)

Convert from geodetic coordinates to local East, North, Up (ENU) coordinates.

getbyattrib(D::Vector{<:GMTdataset}[, index::Bool]; kw...)

Take a GMTdataset vector and return only its elememts that match the condition(s) set by the attrib keywords. Note, this assumes that D has its attrib fields set with usable information.

Parameters

  • attrib or att: keyword with the attribute name used in selection. It can be a single name as in att="NAME_2" or a NamedTuple with the attribname, attribvalue as in att=(NAME_2="value"). Use more elements if wishing to do a composite match. E.g. att=(NAME_1="val1", NAME_2="val2") in which case oly segments matching the two conditions are returned.

  • val or value: keyword with the attribute $value$ used in selection. Use this only when att is not a NamedTuple.

  • index: Use this positional argument = true to return only the segment indices that match the att condition(s).

Returns

Either a vector of GMTdataset, or a vector of Int with the indices of the segments that match the query condition. Or nothing if the query results in an empty GMTdataset

Example:

D = getbyattrib(D, attrib="NAME_2", val="Porto");
gmtread(fname::String; kwargs...)

Read GMT object from file. The object is one of "grid" or "grd", "image" or "img", "data" or "table", "cmap" or "cpt" and "ps" (for postscript), and OGR formats (shp, kml, json). Use a type specificatin to force a certain reading path (e.g. grd=true to read grids) or take the chance of letting the data type be guessed via the file extension. Known extensions are:

  • Grids: .grd, .jp2 .nc

  • Images: .jpg, .jp2 .png, .tif, .tiff, .bmp, .webp

  • Datasets: .dat, .txt, .csv

  • Datasets: .shp, .kml, .json, .geojson, .gmt, .gpkg, .gpx, .gml

  • CPT: .cpt

  • PostScript: .ps, .eps

Parameters

Specify data type (with type=true, e.g. img=true). Choose among:

  • grd | grid :: [Type => Any]

    Load a grid.

  • img | image :: [Type => Any]

    Load an image.

  • cpt | cmap :: [Type => Any]

    Load a GMT color palette.

  • data | dataset | table :: [Type => Any]

    Load a dataset (a table of numbers).

  • ogr :: [Type => Any]

    Load a dataset via GDAL OGR (a table of numbers). Many things can happen here.

  • ps :: [Type => Any]

    Load a PostScript file

  • gdal :: [Type => Any]

    Force reading the file via GDAL. Should only be used to read grids.

  • varname :: [Type => Str]

    When netCDF files have more than one 2D (or higher) variables use varname to pick the wished variable. e.g. varname=:slp to read the variable named 'slp'. This option defaults data type to 'grid'

  • layer | band :: [Type => Str, Number, Array]

When files are multiband or nc files with 3D or 4D arrays, we access them via these keywords. layer=4 reads the fourth layer (or band) of the file. But the file can be a grid or an image. If it is a grid, layer can be a scalar (to read 3D arrays) or an array of two elements (to read a 4D array).

If file is an image layer can be a 1 or a 1x3 array (to read a RGB image). Not that in this later case bands do not need to be contiguous. A band=[1,5,2]` composes an RGB out of those bands. See more at http://docs.generic-mapping-tools.org/latest//GMT_Docs.html#modifiers-for-coards-compliant-netcdf-files) but note that we use 1 based indexing here.

  • R | region | limits :: [Type => Str or list or GMTgrid|image] $Arg = (xmin,xmax,ymin,ymax)$

    Specify the region of interest. Set to data minimum BoundinBox if not provided. (http://docs.generic-mapping-tools.org/latest/gmt.html#r-full)

  • V | verbose :: [Type => Bool or Str] $Arg = [level]$

    Select verbosity level, which will send progress reports to stderr. (http://docs.generic-mapping-tools.org/latest/gmt.html#v-full)

  • bi | binary_in :: [Type => Str] $Arg = [ncols][type][w][+L|+B]$

    Select native binary format for primary input (secondary inputs are always ASCII). (http://docs.generic-mapping-tools.org/latest/gmt.html#bi-full)

  • f | colinfo | coltypes | coltype :: [Type => Str] $Arg = [i|o]colinfo$

    Specify the data types of input and/or output columns (time or geographical data). (http://docs.generic-mapping-tools.org/latest/gmt.html#f-full)

Example: to read a nc called 'lixo.grd'

G = gmtread("lixo.grd");

to read a jpg image with the bands reversed

I = gmtread("image.jpg", band=[2,1,0]);
u, ind = gunique(x::AbstractVector; sorted=false)

Return an array containing only the unique elements of x and the indices ind such that u = x[ind]. If sorted is true the output is sorted (default is not)

hlines(arg; decorated=(...), xmin=NaN, xmax=NaN, percent=false, kwargs...)

Plots one or a collection of horizontal lines with eventual decorations

  • xmin & xmax: Limit the horizontal lines to start a xmin and/or end at xmax

  • percent: If true the xmin & xmax are interpreted as fractions of the figure height.

  • B | frame | axis | xaxis yaxis:: [Type => Str]

    Set map boundary frame and axes attributes. (http://docs.generic-mapping-tools.org/latest/gmt.html#b-full)

  • J | proj | projection :: [Type => String]

    Select map projection. Defaults to 14x9.5 cm with linear (non-projected) maps. (http://docs.generic-mapping-tools.org/latest/gmt.html#j-full)

  • R | region | limits :: [Type => Str or list or GMTgrid|image] $Arg = (xmin,xmax,ymin,ymax)$

    Specify the region of interest. Set to data minimum BoundinBox if not provided. (http://docs.generic-mapping-tools.org/latest/gmt.html#r-full)

  • W | pen | line_attrib :: [Type => Str]

    Set pen attributes for the horizontal lines (http://docs.generic-mapping-tools.org/latest/plot.html#w)

Example:

plot(rand(5,3))
hlines!([0.2, 0.6], pen=(1, :red), show=true)
imagesc(mat; x=, y=, hdr=, proj4=, wkt=, GI=, clim=, cmap=, kw...)

imagesc takes a Float matrix or a GMTgrid type and scales it (by default) to the [0, 255] interval. In the process it creates a GMTimage type. Those types can account for coordinates and projection information, hence the optional arguments. Contrary to its Matlab cousin, it doesn't display the result (that we easily do with imshow(mat)) but return instead a GMTimage object.

  • clim: Specify clims as a two-element vector of the form [cmin cmax], where values of the scaled image less than or equal to cmin are assigned that value. The same goes for cmax.

  • cmap: If provided, cmap is a GMTcpt and its contents is converted to the GMTimage colormp.

  • GI: This can be either a GMTgrid or a GMTimage and its contents is used to set spatial contents (x,y coordinates) and projection info that one may attach to the created image result. This is a handy alterative to the x=, y=, proj4=... options.

I = image_alpha!(img::GMTimage; alpha_ind::Integer, alpha_vec::Vector{Integer}, alpha_band::UInt8)

Change the alpha transparency of the GMTimage object img. If the image is indexed, one can either change just the color index that will be made transparent by using alpha_ind=n or provide a vector of transaparency values in the range [0 255]; This vector can be shorter than the orginal number of colors. Use alpha_band to change, or add, the alpha of true color images (RGB).

Example1: change to the third color in cmap to represent the new transparent color
    image_alpha!(img, alpha_ind=3)

Example2: change to the first 6 colors in cmap by assigning them random values
    image_alpha!(img, alpha_vec=round.(Int32,rand(6).*255))
image_cpt!(img::GMTimage, cpt::GMTcpt, clear=false)

or

image_cpt!(img::GMTimage, cpt::String, clear=false)

Add (or replace) a colormap to a GMTimage object from the colors in the cpt. This should have effect only if IMG is indexed. Use image_cpt!(img, clear=true) to remove a previously existant colormap field in IMG

imshow(arg1; kw...)

Is a simple front end to the grdimage grdview programs that accepts GMTgrid, GMTimage, 2D array of floats or strings with file names of grids or images. The normal options of the grdimage and grdview programs also apply here but some clever guessing of suitable necessary parameters is done if they are not provided. Contrary to other image producing modules the "show' keyword is not necessary to display the image. Here it is set by default. If user wants to use imshow to create layers of a more complex fig he can use show=false for the intermediate layers.

This module uses some internal logic to decide whether use grdimge, grdview or plot. Namely, when the view option is used grdview is choosed and a default vertical scale is assigned. However, sometimes we want a rotated plot, optionally tilted, but not 3D view. In that case use the option flat=true, which forces the use of grdimage.

Examples

# Plot vertical shaded illuminated view of the Mexican hat
julia> G = gmt("grdmath -R-15/15/-15/15 -I0.3 X Y HYPOT DUP 2 MUL PI MUL 8 DIV COS EXCH NEG 10 DIV EXP MUL =");
julia> imshow(G, shade="+a45")

# Same as above but add automatic contours
julia> imshow(G, shade="+a45", contour=true)

# Plot a random heat map
julia> imshow(rand(128,128))

# Display a web downloaded jpeg image wrapped into a sinusoidal projection
julia> imshow("http://larryfire.files.wordpress.com/2009/07/untooned_jessicarabbit.jpg", region="d", frame="g", proj="I15", img_in="r", fmt=:jpg)

See also: grdimage

I = ind2rgb(I::GMTimage, cmap::GMTcpt=GMTcpt(), layout="BRPa")

Convert an indexed image I to RGB. If cmap is not provided, it uses the internal colormap to do the conversion. If neither them exists, the layer is replicated 3 times thus resulting in a gray scale image.

inwhichpolygon(D::Vector{GMTdataset}, point::Matrix{Real})

or

inwhichpolygon(D::Vector{GMTdataset}, x, y)

Finds the IDs of the polygons enclosing the query points in point. Each row in the matrix point contains the coordinates of a query point. Query points that don't fall in any polygon get an ID = 0. Returns either an $Int$ or a $Vector{Int}$ depending on the number of input quiery points.

  • D: A Vector of GMTdadaset defining the polygons.

  • point: A Mx2 matrix or a two elements vector with the x and y point coordinates.

  • x, y: Specifies the x-coordinates and y-coordinates of 2-D query points as separate vectors (or two scalars).

Example:

pts = [[1 2 3;1 2 3;1 2 3][:] [1 1 1;2 2 2; 3 3 3][:]];
D = triplot(pts, noplot=true);
points = [2.4 1.2; 1.4 1.4];
ids = inwhichpolygon(D, points);
# Plot the triangulation and the query points.
plot(D)
plot!(D[ids[1]], fill=:grey)
plot!(D[ids[2]], fill=:green)
plot!(points, marker=:star, ms="12p", fill=:blue, show=true)

No documentation found.

GMT.isnodata is a Function.

# 2 methods for generic function "isnodata" from GMT:
 [1] isnodata(array::AbstractArray)
     @ ~/.julia/packages/GMT/H3fhl/src/utils.jl:328
 [2] isnodata(array::AbstractArray, val)
     @ ~/.julia/packages/GMT/H3fhl/src/utils.jl:328
kml2gmt(cmd0::String="", arg1=nothing, kwargs...)

kml2gmt - Extract GMT table data from Google Earth KML files

Full option list at kml2gmt

Parameters

  • F | select :: [Type => Str] $Arg = s|l|p$

    Specify a particular feature type to output. Choose from points (s), line (l), or polygon (p). By default we output all geometries. (http://docs.generic-mapping-tools.org/latest/kml2gmt.html#f)

  • Z | altitudes :: [Type => Bool]

    Output the altitude coordinates as GMT z coordinates [Default will output just longitude and latitude]. (http://docs.generic-mapping-tools.org/latest/kml2gmt.html#z)

  • V | verbose :: [Type => Bool or Str] $Arg = [level]$

    Select verbosity level, which will send progress reports to stderr. (http://docs.generic-mapping-tools.org/latest/gmt.html#v-full)

  • bo | binary_out :: [Type => Str] $Arg = [ncols][type][w][+L|+B]$

    Select native binary output. (http://docs.generic-mapping-tools.org/latest/gmt.html#bo-full)

  • do | nodata_out :: [Type => Str or Number] $Arg = nodata$

    Examine all output columns and if any item equals NAN substitute it with the chosen missing data value. (http://docs.generic-mapping-tools.org/latest/gmt.html#do-full)

  • yx :: [Type => Str or Bool or []] $Arg = [i|o]$

    Swap 1st and 2nd column on input and/or output. (http://docs.generic-mapping-tools.org/latest/gmt.html#colon-full)

linearfitxy(X, Y; σX=0, σY=0, r=0, ci=95)

Performs 1D linear fitting of experimental data with uncertainties in X and Y:

  • Linear fit: Y = a + b*X [1]

  • Errors: $X ± σX; Y ± σY$ [2]

  • Errors' correlation: $r = = cov(σX, σY) / (σX * σY)$ [3]

Arguments:

  • X and Y are input data vectors with length ≥ 3

  • Optional standard deviation errors $σX$ and $σY$ are vectors or scalars

  • Optional r is the correlation between the $σX$ and $σY$ errors. r can be a vector or scalar

  • ci is the confidence interval for the statistics. By default it's 95% but any integer number > 0 < 100 will do.

$σX$ and $σY$ errors (error ellipses) with bivariate Gaussian distribution assumed. If no errors, or if only $σX$ or $σY$ are provided, then the results are equivalent to those from the LsqFit.jl package.

Based on York et al. (2004) with extensions (confidence intervals, diluted corr. coeff.).

Examples:

D = linearfitxy(X, Y)    # no errors in X and Y, no plot displayed

D = linearfitxy(X, Y; σX, σY) # XY errors not correlated (r=0);

D = linearfitxy([91., 104, 107, 107, 106, 100, 92, 92, 105, 108], [9.8, 7.4, 7.9, 8.3, 8.3, 9.0, 9.7, 8.8, 7.6, 6.9]);

D = linearfitxy([0.0, 0.9, 1.8, 2.6, 3.3, 4.4, 5.2, 6.1, 6.5, 7.4], [5.9, 5.4, 4.4, 4.6, 3.5, 3.7, 2.8, 2.8, 2.4, 1.5], sx=1 ./ sqrt.([1000., 1000, 500, 800, 200, 80,  60, 20, 1.8, 1]), sy=1 ./ sqrt.([1., 1.8, 4, 8, 20, 20, 70, 70, 100, 500]));

D = linearfitxy([0.037 0.0080; 0.035 0.0084; 0.032 0.0100; 0.040 0.0085; 0.013 0.0270; 0.038 0.0071; 0.042 0.0043; 0.030 0.0160], sx=0.03, sy=0.1, r=0.7071);

The results are added as new columns of a GMTdataset structure when they are vectors (σX σY r) and stored as attributes when they are scalars (a, b, σa, σb, σa95, σb95, ρ and S):

  • The intercept a, the slope b and their uncertainties σa and σb

  • $σa95$ and $σb95$: 95%-confidence interval using two-tailed t-Student distribution, e.g.: $b ± σb95 = b ± t(0.975,N-2)*σb$

  • Goodness of fit S (reduced $Χ²$ test): quantity with $Χ²$ N-2 degrees of freedom S ~ 1: fit consistent with errors, S > 1: poor fit, S >> 1: errors underestimated, S < 1: overfitting or errors overestimated

  • Pearson's correlation coefficient $ρ$ that accounts for data errors

For more information and references see the LinearFitXYerrors.jl package at https://github.com/rafael-guerra-www/LinearFitXYerrors.jl

logo(cmd0::String=""; kwargs...)

Plots the GMT logo on a map. By default, the GMT logo is 5 cm wide and 2.5 cm high and will be positioned relative to the current plot origin. Use various options to change this and to place a transparent or opaque rectangular map panel behind the GMT logo.

Full option list at gmtlogo

Parameters

  • D | pos | position :: [Type => Str]

    Sets reference point on the map for the image using one of four coordinate systems. (http://docs.generic-mapping-tools.org/latest/gmtlogo.html#d)

  • F | box :: [Type => Str]

    Without further options, draws a rectangular border around the GMT logo using MAP_FRAME_PEN. or map rose (T) (http://docs.generic-mapping-tools.org/latest/gmtlogo.html#f)

  • julia :: [Type => Number]

    Create the Julia instead of the GMT logo. Provide circle diameter in centimeters

  • GMTjulia :: [Type => Number]

    Create the GMT Julia GMT logo. Provide circle diameter in centimeters

  • J | proj | projection :: [Type => String]

    Select map projection. Defaults to 14x9.5 cm with linear (non-projected) maps. (http://docs.generic-mapping-tools.org/latest/gmt.html#j-full)

  • Jz | zscale | zsize :: [Type => String]

  • P | portrait :: [Type => Bool or []]

    Tell GMT to NOT draw in portrait mode (that is, make a Landscape plot)

  • R | region | limits :: [Type => Str or list or GMTgrid|image] $Arg = (xmin,xmax,ymin,ymax)$

    Specify the region of interest. Set to data minimum BoundinBox if not provided. (http://docs.generic-mapping-tools.org/latest/gmt.html#r-full)

  • U | time_stamp | timestamp :: [Type => Str or Bool or []] $Arg = [[just]/dx/dy/][c|label]$

    Draw GMT time stamp logo on plot. (http://docs.generic-mapping-tools.org/latest/gmt.html#u-full)

  • V | verbose :: [Type => Bool or Str] $Arg = [level]$

    Select verbosity level, which will send progress reports to stderr. (http://docs.generic-mapping-tools.org/latest/gmt.html#v-full)

  • X | x_offset | xshift :: [Type => Str] $Arg = [a|c|f|r][x-shift[u]]$

  • Y | y_offset | yshift :: [Type => Str] $Arg = [a|c|f|r][y-shift[u]]$

    Shift plot origin relative to the current origin by (x-shift,y-shift) and optionally append the length unit (c, i, or p). (http://docs.generic-mapping-tools.org/latest/gmt.html#xy-full)

  • t | alpha | transparency :: [Type => Str] $Arg = transp$

    Set PDF transparency level for an overlay, in (0-100] percent range. [Default is 0, i.e., opaque]. (http://docs.generic-mapping-tools.org/latest/gmt.html#t-full)

  • savefig | figname | name :: [Type => Str]

    Save the figure with the figname=name.ext where ext chooses the figure format (e.g. figname="name.png")

  • Example, make a GMT Julia logo with circles of 1 cm: logo(GMTjulia=1, show=true)

No documentation found.

GMT.magic is a Function.

# 1 method for generic function "magic" from GMT:
 [1] magic(n::Int64)
     @ ~/.julia/packages/GMT/H3fhl/src/utils.jl:435
D = mat2ds(mat [,txt]; x=nothing, text=nothing, multi=false, geom=0, kwargs...)

Take a 2D mat array and convert it into a GMTdataset. x is an optional coordinates vector (must have the same number of elements as rows in mat). Use x=:ny to generate a coords array 1:nrows of mat. Alternatively, if mat is a string or vector of strings we return a dataset with NaN's in the place of the coordinates. This form is useful to pass to text when using the `regionjustify` option that does not need explicit coordinates to place the text.

  • txt: Return a Text record which is a Dataset with data = Mx2 and text in third column. The $text$ can be an array with same size as mat rows or a string (will be reapeated n_rows times.)

  • x: An optional vector with the xx coordinates

  • hdr: optional String vector with either one or n_rows multisegment headers.

  • lc or linecolor or color: optional array of strings/symbols with color names/values. Its length can be smaller than n_cols, case in which colors will be cycled. If color is not an array of strings, e.g.

 `color="yes"`, the colors cycle trough a pre-defined set of colors (same colors as in Matlab). If you
 want the same color repeated for many lines pass color as a vector. *e.g,* `color=[color]`
  • linethick or lt: for selecting different line thicknesses. Works like color, but should be a vector of numbers, or just a single number that is then applied to all lines.

  • fill: Optional string array (or a String of comma separated color names, or a Tuple of color names) with color names or array of "patterns".

  • fillalpha : When fill option is used, we can set the transparency of filled polygons with this option that takes in an array (vec or 1-row matrix) with numeric values between [0-1] or ]1-100],

 where 100 (or 1) means full transparency.
  • is3D: If input 'mat' contains at least x,y,z (?).

  • ls or linestyle: Line style. A string or an array of strings with length = size(mat,2) with line styles.

  • front: Front Line style. A string or an array of strings with length = size(mat,2) with front line styles.

  • pen: A full pen setting. A string or an array of strings with length = size(mat,2) with pen settings. This differes from lt in the sense that lt does not directly set the line thickness.

  • multi or multicol: When number of columns in mat > 2, or == 2 and x != nothing, make an multisegment Dataset with first column and 2, first and 3, etc. Convenient when want to plot a matrix where each column is a line.

  • segnan or nanseg: Boolean. If true make a multisegment made out of segments separated by NaNs.

  • datatype: Keep the original data type of mat. Default, converts to Float64.

  • geom: The data geometry. By default we set wkbUnknown but try to do some basic guess.

  • proj or proj4: A proj4 string for dataset SRS.

  • wkt: A WKT SRS.

  • colnames: Optional string vector with names for each column of mat.

  • attrib: Optional dictionary{String, String} with attributes of this dataset.

  • ref: Pass in a reference GMTdataset from which we'' take the georeference info as well as attrib and colnames

  • txtcol or textcol: Vector{String} with text to add into the .text field. Warning: no testing is done to check if $length(txtcol) == size(mat,1)$ as it must.

G = mat2grid(mat; reg=nothing, x=[], y=[], v=[], hdr=nothing, proj4::String="",
             wkt::String="", tit::String="", rem::String="", cmd::String="",
			 names::Vector{String}=String[], scale::Float32=1f0, offset::Float32=0f0)

ITake a 2/3D mat array and a HDR 1x9 [xmin xmax ymin ymax zmin zmax reg xinc yinc] header descriptor and return a grid GMTgrid type. Alternatively to HDR, provide a pair of vectors, x & y, with the X and Y coordinates. Optionaly add a v vector with vertical coordinates if mat is a 3D array and one wants to create a $cube$. Optionaly, the HDR arg may be ommited and it will computed from mat alone, but then x=1:ncol, y=1:nrow When HDR is not used, REG == nothing [default] means create a gridline registration grid and REG == 1, or REG="pixel" a pixel registered grid.

For 3D arrays the names option is used to give a description for each layer (also saved to file when using a GDAL function).

The scale and offset options are used when mat is an Integer type and we want to save the grid with an scale/offset.

Other methods of this function do:

G = mat2grid([val]; hdr=hdr_vec, reg=nothing, proj4::String="", wkt::String="", tit::String="", rem::String="")

Create Float GMTgrid with size, coordinates and increment determined by the contents of the HDR var. This array, which is now MANDATORY, has either the same meaning as above OR, alternatively, containng only [xmin xmax ymin ymax xinc yinc] VAL is the value that will be fill the matrix (default VAL = Float32(0)). To get a Float64 array use, for example, VAL = 1.0 Ay other non Float64 will be converted to Float32

Example: mat2grid(1, hdr=[0. 5 0 5 1 1])

G = mat2grid(f::Function, x, y; reg=nothing, proj4::String="", wkt::String="", epsg::Int=0, tit::String="", rem::String="")

Where F is a function and X,Y the vectors coordinates defining it's domain. Creates a Float32 GMTgrid with size determined by the sizes of the X & Y vectors.

Example: f(x,y) = x^2 + y^2;  G = mat2grid(f, x = -2:0.05:2, y = -2:0.05:2)

G = mat2grid(f::String)

Whre f is a pre-set function name. Currently available:

  • "ackley", "eggbox", "sombrero", "parabola" and "rosenbrock"

X,Y are vectors coordinates defining the function's domain, but default values are provided for each function. creates a Float32 GMTgrid.

Example: G = mat2grid("sombrero")
I = mat2img(mat::Array{<:Unsigned}; x=[], y=[], hdr=nothing, proj4="", wkt="", cmap=nothing, kw...)

Take a 2D 'mat' array and a HDR 1x9 [xmin xmax ymin ymax zmin zmax reg xinc yinc] header descriptor and return a GMTimage type. Alternatively to HDR, provide a pair of vectors, x & y, with the X and Y coordinates. Optionaly, the HDR arg may be ommited and it will computed from 'mat' alone, but then x=1:ncol, y=1:nrow When 'mat' is a 3D UInt16 array we automatically compute a UInt8 RGB image. In that case 'cmap' is ignored. But if no conversion is wanted use option noconv=true

I = mat2img(mat::Array{UInt16}; x=[], y=[], hdr=nothing, proj4::String="", wkt::String="", kw...)

Take a mat array of UInt16 and scale it down to UInt8. Input can be 2D or 3D. If the kw variable stretch is used, we stretch the intervals in stretch to [0 255]. Use this option to stretch the image histogram. If stretch is a scalar, scale the values > stretch to [0 255]

  • stretch = [v1 v2] scales all values >= v1 && <= v2 to [0 255]

  • stretch = [v1 v2 v3 v4 v5 v6] scales firts band >= v1 && <= v2 to [0 255], second >= v3 && <= v4, same for third

  • stretch = :auto | "auto" | true | 1 will do an automatic stretching from values obtained from histogram thresholds

The kw... kwargs search for [:layout :mem_layout], [:names] and [:metadata]

pcolor(X, Y, C::Matrix{<:Real}; kwargs...)

Creates a colored cells plot using the values in matrix C. The color of each cell depends on the value of each value of C after consulting a color table (cpt). If a color table is not provided via option cmap=xxx we compute a default one.

  • X, Y: Vectors or 1 row matrices with the x- and y-coordinates for the vertices. The number of elements of X must match the number of columns in C (is using the grid registration model) or exceed it by one (pixel registration). The same for Y and the number of rows in C. Notice that X and Y do not need to be equispaced.

  • X, Y: Matrices with the x- and y-coordinates for the vertices. In this case the if X and Y define an m-by-n grid, then C should be an (m-1)-by-(n-1) matrix, though we also allow it to be m-by-n but we then drop the last row and column from C

  • C: A matrix with the values that will be used to color the cells.

  • kwargs: This form of pcolor is in fact a wrap up of $plot$ so any option of that module can be used here.

  • labels: If this $keyword$ is used then plot the value of each node in the corresponding cell. Use label=n, where $n$ is integer and represents the number of printed decimals. Any other value like $true$, $"y"$ or $:y$ tells the program to guess the number of decimals.

  • font: When label is used one may also control text font settings. Options are a subset of the $text$ attrib option. Namelly, the angle and the $font$. Example: $font=(angle=45, font=(5,:red))$. If not specified, it defaults to $font=(font=(6,:black),)$.

pcolor(G::GMTgrid; kwargs...)

This form takes a grid (or the file name of one) as input an paints it's cell with a constant color.

  • outline: Draw the tile outlines, and specify a custom pen if the default pen is not to your liking.

  • kwargs: This form of pcolor is a wrap of $grdview$ so any option of that module can be used here. One can for example control the tilling option via $grdview's$ $tiles$ option.

Examples

# Create an example grid
G = GMT.peaks(N=21);

pcolor(G, outline=(0.5,:dot), show=true)

# Now use the G x,y coordinates in the non-regular form
pcolor(G.x, G.y, G.z, show=true)

# Add labels to cells using default settings (font size = 6p)
pcolor(G.x, G.y, G.z, labels=:y, show=true)

# Similar to above but now set the number of decimlas in labels as well as it font settings
pcolor(G.x, G.y, G.z, labels=2, font=(angle=45, font=(5,:red)), show=1)

# An irregular grid
X,Y = GMT.meshgrid(-3:6/17:3);
XX = 2*X .* Y;	YY = X.^2 .- Y.^2;
pcolor(XX,YY, reshape(repeat([1:18; 18:-1:1], 9,1), size(XX)), lc=:black, show=true)

plotyy(arg1, arg2; kwargs...)

Example:

plotyy([1 1; 2 2], [1.5 1.5; 3 3], R="0.8/3/0/5", title="Ai", ylabel=:Bla, xlabel=:Ble, seclabel=:Bli, show=1)
x, y = pol2cart(theta, rho; deg=false)

Transform polar to Cartesian coordinates. Angles are in radians by default. Use deg=true if angles are in degrees. Input can be scalar, vectors or matrices.

zvals = polygonlevels(D::GDtype, ids::Vector{String}, vals::Vector{<:Real}; kw...) -> Vector{Float64}

or

zvals = polygonlevels(D::GDtype, ids::Matrix{String}, vals::Vector{<:Real}; kw...) -> Vector{Float64}

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. 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 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 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 made up from the contents of vals but may be repeated such that each polygon of the same family, i.e. with the same ids, has the same value.

rasterzones!(GI::GItype, shapes::Vector{GMTdataset}, fun::Function)

Apply a unidimensional function fun to to the elements of the grid or image GI that lie inside the polygons of the GMTdataset shapes. The GI array is modified in place.

Parameters

  • GI: A grid (GMTgrid) or image (GMTimage) type that will be modified by applying fun to the elements that fall inside the polygons of shapes.

  • shapes: A vector of GMTdataset containing the polygons inside which the elements if GI will be assigned a single value obtained by applying the function fun.

  • fun: A unidemensional function name used to compute the contant value for the GI elements that fall inside each of the polygons of shapes.

See also: colorzones!

Returns

It does't return anything but the input GI is modified.

Example

Take the Peaks grid and replace the elements that fall inside a triangle at the center by their average.

G = GMT.peaks();
D = mat2ds([-1 -1; 0 1; 1 -1; -1 -1]);
rasterzones!(G, D, mean)
regiongeog(GI)::Tuple

Returns a tuple with (lonmin, lonmax, latmin, latmax) of the projected GI object limits converted to geographic coordinates. Returns an empty tuple if GI has no registered referencing system. GI can either a GMTgrid, a GMTimage or a file name (String) of one those types.

R = rescale(A, a=0.0, b=1.0; inputmin=nothing, inputmax=nothing, stretch=false, type=nothing)
  • A: is either a GMTgrid, GMTimage, Matrix{AbstractArray} or a file name. In later case the file is read with a call to gmtread that automatically decides how to read it based on the file extension ... not 100% safe.

  • rescale(A) rescales all entries of an array A to [0,1].

  • rescale(A,b,c) rescales all entries of A to the interval [b,c].

  • rescale(..., inputmin=imin) sets the lower bound imin for the input range. Input values less than imin will be replaced with imin. The default is min(A).

  • rescale(..., inputmax=imax) sets the lower bound imax for the input range. Input values greater than imax will be replaced with imax. The default is max(A).

  • rescale(..., stretch=true) automatically determines [inputmin inputmax] via a call to histogram that will (try to) find good limits for histogram stretching.

  • type: Converts the scaled array to this data type. Valid options are all Unsigned types (e.g. UInt8). Default returns the same data type as A if it's an AbstractFloat, or Flot64 if A is an integer.

Returns a GMTgrid if A is a GMTgrid of floats, a GMTimage if A is a GMTimage and type is used or an array of Float32|64 otherwise.

slicecube(I::GMTimage, layer::Int)

Take a slice of a multylayer GMTimage. Return the result still as a GMTimage. layer is the z slice number.

slicecube(G::GMTgrid, slice; axis="z")

Extract a slice from a GMTgrid cube.

  • slice: If it is an Int it will return a GMTgrid corresponding to that layer. However, if slice is a float this is interpreted to mean: search that dimension (see the axis below) coordinates and find the closest layer that has coordinate = slice. If the slice value is not within 10% of the coordinate of closest layer, the returned layer is obtained by linear interpolation of the neighboring layers. For example, slice=2.5 on a cube were layers are one unit apart will interpolate between layers 2 and 3 where each layer weights 50% in the end result. NOTE: the return type is still a cube but with one layer only (and the corresponding axis coordinate).

  • axis: denotes the dimension being sliced. The default, "z", means the slices are taken from the vertical axis. axis="x" means slice along a column, and axis="y" slice along a row.

slicecube(GI::GItype; slice::Int=0, angle=0.0, axis="x", cmap=GMTcpt())

Take a slice of a GMTgrid or GMTimage in an oblique direction. Take the cube's layer slice and rotate it by angle degrees about the axis. This one can only be axis=:x or axis=:y. Depending on the data type of input a different output is produces. If GI is a GMTgrid, the output is 2 GMTgrids: one with z levels and the other with cube's z levels along that plane. On the other hand, if GI isa GMTimage the first output is similar to previus case but the second will be a GMTimage. In this case the cmap option may be used to assign a colortable to the image type.

The value at the slice point, P(x[i,j], y[i,j], z[i, j)), is the interpolated value of the two nearest voxels on the same vertical.

Example

Get the fourth layer of the multi-layered 'I' GMTimage object

I = slicecube(I, 4)
x, y, z = sph2cart(az, elev, rho; deg=false)

Transform spherical coordinates to Cartesian. Angles are in radians by default. Use deg=true if angles are in degrees. Input can be scalar, vectors or matrices.

stackgrids(names::Vector{String}, v=nothing; zcoord=nothing, zdim_name="time",
           z_unit="", save="", mirone=false)

Stack a bunch of single grids in a multiband cube like file.

  • names: A string vector with the names of the grids to stack

  • v: A vector with the vertical coordinates. If not provided one with 1:length(names) will be generated.

    • If v is a TimeType use the z_unit keyword to select what to store in file (case insensitive).

      • decimalyear or yeardecimal converts the DateTime to decimal years (Floa64)

      • milliseconds (or just mil) will store the DateTime as milliseconds since 0000-01-01T00:00:00 (Float64)

      • seconds stores the DateTime as seconds since 0000-01-01T00:00:00 (Float64)

      • unix stores the DateTime as seconds since 1970-01-01T00:00:00 (Float64)

      • rata stores the DateTime as days since 0000-12-31T00:00:00 (Float64)

      • Date or DateTime stores as a string representation of a DateTime.

  • zdim_name: The name of the vertical axes (default is "time")

  • zcoord: Keyword same as v (may use one or the other).

  • save: The name of the file to be created.

  • mirone: Does not create a cube file but instead a file named "automatic_list.txt" (or whaterver save=xxx) to be used in the Mirone Empilhador tool.

S = streamlines(U::GMTgrid, V::GMTgrid, startX, startY; step=0.1, max_vert::Int=10000)

Compute 2-D streamlines as a 2-D matrix (in fact, a GMTdataset) of vector fields. The inputs U and V are GMTgrids with the x and y velocity components, and startX and startY are the starting positions of the streamlines. step is the step size in data units for interpolating the vector data and max_vert is the maximum number of vertices in a streamline. startX and startY can both be scalars, vectors or one a scalar and the other a vector. Returns a Vector{GMTdataset} with the streamlines.

S = streamlines(U::GMTgrid, V::GMTgrid, D::GMTdataset; step=0.1, max_vert::Int=10000)

In this method the streamlines starting positions are fetch from the 2 columns of the D argument. Returns a Vector{GMTdataset} with the streamlines.

S, A = streamlines(U::GMTgrid, V::GMTgrid; step=0.1, max_vert::Int=10000)

Method that computes automatically spaced streamlines from 2D grids U and V. Returns the streamlines in the S Vector{GMTdataset} and A holds the positions along the streamlines where to plot arrow-heads if wished.

S = streamlines(U::GMTgrid, V::GMTgrid; side::Union{String, Symbol}="left", step=0.1, max_vert::Int=10000)

Here we auto-generate the starting positions along one of the 4 sides of the grid. Select the wished side with the side keyword. Returns a Vector{GMTdataset} with the streamlines.

S = streamlines(x, y, U::Matrix, V::Matrix, sx, sy; step=0.1, max_vert::Int=10000)

This last 2D method let users pass the x and y vector data coordinates, U and V are matrices with the velocity data and the remaining arguments have the same meaning as in the other methods. Returns a Vector{GMTdataset} with the streamlines.

S = streamlines(U::GMTgrid, V::GMTgrid, W::GMTgrid, startX, startY, startZ; step=0.1, max_vert::Int=10000)

Conpute 3D volume of vector fields with streamline. Here U,V and W are 3D cubes with x,y,z velocity components. startX, startY and startZ can be scalar or vector coordinate arrays. Returns a Vector{GMTdataset} with the streamlines.

Example

x,y = GMT.meshgrid(-10:10);
u = 2 .* x .* y;
v = y .^2 - x .^ 2;
U = mat2grid(u, x[1,:], y[:,1]);
V = mat2grid(v, x[1,:], y[:,1]);
r,a = streamlines(U, V);
plot(r, decorated=(locations=a, symbol=(custom="arrow", size=0.3), fill=:black, dec2=true), show=1)
tern2cart(abcz::Matrix{<:Real}, reverse::Bool=false)

Converts ternary to cartesian units.

abcz is either a Mx3 (a,b,c) or Mx4 (a,b,c,z) matrix

theme(name; kwrgs...)

Offer themes support. NAME is the theme name. So far the three options are:

  • modern: - This is the default theme (same as GMT modern theme but with thinner FRAME_PEN [0.75p])

  • classic: - The GMT classic theme

  • dark: - A modern theme variation with dark background.

  • A0|2[XY|XX|YY][atg][ag][g][H][V][NT|nt][ITit][Graph][Dark] Make a composition of these to select a theme. The main condition is that it starts with an A (Annotate). Hence A2 means annotate two axis and A0 means no axes at all. XY means to plot only left and bottom axes, YY only left and right and XX bottom and top. atg (or afg) means annotate, tick and grid lines. ag does not tick. H and V means grid lines will only be horizontal or vertical. Note, these require atg or ag. NT stands for no ticks at all and IT plots the ticks inside the axes. Graph adds a vector to the end of each axis (sets XY), and Dark put the background in dark mode.

    • Example: A2YYg -> plot left and right axes (only) and add grid lines.

    • Example: A2Graph -> plot left and right axes (only) and adds arrows at the end of them

On top of the modern mode variations (so far dark only) one can set the following kwargs options:

  • noticks or no_ticks: Axes will have annotations but no tick marks

  • inner_ticks or innerticks: - Ticks will be drawn inside the axes instead of outside.

  • gray_grid or graygrid: - When drawing grid line use gray instead of black

  • save: - Save the name in the directory printed by GMT.GMTuserdir[1] and make it permanent.

  • reset: - Remove the saved theme name and return to the default modern theme.

Note: Except save and reset, the changes operated by the kwargs are temporary and operate only until an image is show(n) or saved.

This function can be called alone, e.g. theme("dark") or as an option in the plot() module.

triplot(in::Matrix; onlyedges::Bool=false, noplot::Bool=false, kw...)

Plots the 2-D triangulation or Voronoi polygons defined by the points in a matrix

  • in: The input data. Can be either a Mx2 or Mx3 matrix.

  • noplot: Return the computed Delaunay or Veronoi data instead of plotting it (the default).

  • onlyedges: By default we compute Delaunay tringles or Veronoi cells as polygons. Use this option as onlyedges=true to compute multiple line segments.

  • region: Sets the data region (xmin,xmax,ymin,ymax) for voronoi (required). If not provided we compute it from in.

  • voronoi: Compute Voronoi cells instead of Delaunay triangles (requires region).

  • kw...: Are keyword arguments used in the $plot$ module (ignore if noplot=true).

Returns

A GMTdataset if noplot=true or $nothing$ otherwise.

Example:

triplot(rand(5,2), voronoi=true, show=true)

triplot(rand(5,3), lc=:red, show=true)

ind = uniqueind(x)

Return the index ind such that x[ind] gets the unique values of x. No sorting is done

angles, ind = vecangles(lonlat0::VecOrMat{Real}, lonlat1::Matrix{Real}; proj::String="",
                        s_srs::String="", epsg::Integer=0, sorted=true)

Computes the angles between lines taken from the central point lonlat0 and those passed in the Mx2 matrix lonlat1.

Args:

  • lonlat1: - coordinates of point 1 in the given projection (or a matrix with several points).

  • lonlat2: - coordinates of point 2 in the given projection (or a matrix with same size as lonlat1).

  • proj or s_srs: - the given projection whose ellipsoid we move along. Can be a proj4 string or an WKT.

  • epsg: - Alternative way of specifying the projection [Default is WGS84].

  • sorted: - By default we sort the lines azimuth so that the angles refer to contiguous line. If sorted is set to false we compute the angles in the order of points as given in lonlat2.

Returns

  • angles - A Float64 vector with the angles between center and points determined by the arguments plus the angle betwen the lines from center to first and from center to last point.

  • ind - A vector of Int with the order obtained by sorting the lines azimuths (when sorted=true). Apply it to lonlat2[ind,:] to get the point distribution order in the same way as angles. Neddless, ofc, if sorted=false.

vlines(arg; decorated=(...), ymin=NaN, ymax=NaN, percent=false, kwargs...)

Plots one or a collection of vertical lines with eventual decorations

  • ymin & ymax: Limit the vertical lines to start a ymin and/or end at ymax

  • percent: If true the xmin & xmax are interpreted as fractions of the figure width.

  • B | frame | axis | xaxis yaxis:: [Type => Str]

    Set map boundary frame and axes attributes. (http://docs.generic-mapping-tools.org/latest/gmt.html#b-full)

  • J | proj | projection :: [Type => String]

    Select map projection. Defaults to 14x9.5 cm with linear (non-projected) maps. (http://docs.generic-mapping-tools.org/latest/gmt.html#j-full)

  • R | region | limits :: [Type => Str or list or GMTgrid|image] $Arg = (xmin,xmax,ymin,ymax)$

    Specify the region of interest. Set to data minimum BoundinBox if not provided. (http://docs.generic-mapping-tools.org/latest/gmt.html#r-full)

  • W | pen | line_attrib :: [Type => Str]

    Set pen attributes for the horizontal lines (http://docs.generic-mapping-tools.org/latest/plot.html#w)

Example:

plot(rand(5,3), region=[0,1,0,1])
vlines!([0.2, 0.6], pen=(1, :red), show=true)
wmsinfo(server::String)

Read the xml information from the WebMapServer service and create a WMS data type that holds the information necessary to download the data. The show method will display the contents of the WMS data type.

  • server: The server URL address.

Example

wms = wmsinfo("http://tiles.maps.eox.at/wms?")

As an option, use the form

wmsinfo(wms::WMS; layer)

to get further information, in particular the number of bands and sizes, of the layer number or layer name layer. wms is returned by the first form.

wmsread(wms::WMS; layer, kwargs...)

Read the layer number provided by the service from which the wms type was created.

Parameters

  • wms: A WMS type obtained from the wmsinfo function.

  • layer: The layer number or layer name of interest from those provided by the WMS service. That is, both of these forms are allowed: layer=3 or layer="Invented layer name"

kwargs is the keywords/values pairs used to set

  • region | limits: The region limits. This can be a Tuple or Array with 4 elements defining the (xmin, xmax, ymin, ymax) or a string defining the limits in all ways that GMT can recognize. When the layer has the data projected, we can a Tuple or Array with 3 elements (lon0, lat0, width), where first two set the center of a square in geographical coordinates and the third (width) is the width of that box in meters.

  • cellsize | pixelsize | resolution | res: Sets the requested cell size in meters [default]. Use a string appended with a 'd' (e.g. resolution="0.001d") if the resolution is given in degrees. This way works only when the layer is in geogs.

  • size: Alternatively to the the cellsize use this option, a tuple or array with two elements, to specify the image dimensions. Example, size=(1200, 100) to get an image with 1200 rows and 100 columns.

  • time: Some services provide data along time. Use this option to provide a time string as provided by DateTime. For example: time=string(DateTime(2021,10,29))

Returns

A GMTimage

Examples

wms = wmsinfo("http://tiles.maps.eox.at/wms?")
img = wmsread(wms, layer=3, region=(-10,-5,37,44), pixelsize=500);

# Retrieve and display a MODIS image
wms = wmsinfo("https://gibs-c.earthdata.nasa.gov/wms/epsg4326/best/wms.cgi");
img = wmsread(wms, layer="MODIS_Terra_CorrectedReflectance_TrueColor", region=(9,22,32,43), time="2021-10-29T00:00:00", pixelsize=750);
imshow(img, proj=:guess)
wmstest(wms::WMS; layer, size::Bool=false, kwargs...)

Test function that generates the GetMap request string or the size of the resulting image given the requested resolution. It is meant to generate first the command that gets the image/grid but not running it. Specially usefull to check that the resulting image size is not huge.

Parameters

  • wms: A WMS type obtained from the wmsinfo function.

  • layer: The layer number or layer name of interest from those provided by the WMS service. That is, both of these forms are allowed: layer=3 or layer="Invented layer name"

  • size: If false, returns the GetMap request string, otherwise the image size given the requested resolution.

kwargs is the keywords/values pairs used to set

  • region | limits: The region limits. This can be a Tuple or Array with 4 elements defining the (xmin, xmax, ymin, ymax) or a string defining the limits in all ways that GMT can recognize. When the layer has the data projected, we can a Tuple or Array with 3 elements (lon0, lat0, width), where first two set the center of a square in geographical coordinates and the third (width) is the width of that box in meters.

  • cellsize | pixelsize | resolution | res: Sets the requested cell size in meters [default]. Use a string appended with a 'd' (e.g. resolution="0.001d") if the resolution is given in degrees. This way works only when the layer is in geogs.

Returns

Either a the GetMap request string (when size=false) or the resulting image/grid size dim_x, dim_y

Example

wmstest(wms, layer=34, region=(-8,39, 100000), pixelsize=100)

"WMS:http://tiles.maps.eox.at/?SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=s2cloudless-2020_3857&SRS=EPSG:900913&BBOX=-940555.9,4671671.6,-840555.9,4771671.68&FORMAT=image/jpeg&TILESIZE=256&OVERVIEWCOUNT=18&MINRESOLUTION=0.59716428347794&TILED=true"
xyzw2cube(fname::AbstractString; datatype::DataType=Float32, proj4::String="", wkt::String="",
          epsg::Int=0, tit::String="", names::Vector{String}=String[])

Convert data table containing a cube into a GMTgrid cube. The input data must contain a completelly filled 3D matrix and the data layout is guessed from file analysis (if it fails ... bad chance).

Parameters

  • fname: The filename of the cube in text format

  • datatype: The data type where the data will be stored. The default is Float32.

  • tit: A title string to describe this cube.

  • proj4: A proj4 string for dataset SRS.

  • wkt: Projection given as a WKT SRS.

  • epsg: Same as proj but using an EPSG code

  • names: used to give a description for each layer (also saved to file when using a GDAL function).

Returns

A GMTgrid cube object.

yeardecimal(date)

Convert a Date or DateTime or a string representation of them to decimal years.

Example

yeardecimal(now())