From f77871b7012a02e39af26112b75a28ff9b44247a Mon Sep 17 00:00:00 2001 From: Joaquim Date: Mon, 22 Jul 2024 00:02:48 +0100 Subject: [PATCH] More --- Project.toml | 1 + documentation/all_docs_ref/all_refs.md | 12 ++++----- documentation/modules/clip.md | 12 +++++++++ documentation/modules/coast.md | 4 +-- documentation/modules/grdimage.md | 30 ++++++++++++++++++----- documentation/utilities/inwhichpolygon.md | 14 +++++------ 6 files changed, 51 insertions(+), 22 deletions(-) diff --git a/Project.toml b/Project.toml index 3bfe9fef4..64ef3339e 100644 --- a/Project.toml +++ b/Project.toml @@ -17,6 +17,7 @@ ImageIO = "82e4d734-157c-48bb-816b-45c225c6df19" ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1" ImageTransformations = "02fcd773-0e25-5acc-982a-7f6622650795" JSServe = "824d6782-a2ef-11e9-3a09-e5662e0c26f9" +Meshes = "eacbb407-ea5a-433e-ab97-5258b1ca43fa" NCDatasets = "85f8d34a-cbdd-5861-8df4-14fed0d494ab" NodeJS = "2bd173c7-0d6d-553b-b6af-13a54713934c" PrettyTables = "08abe8d2-0d0c-5749-adfa-8a2ac140af0d" diff --git a/documentation/all_docs_ref/all_refs.md b/documentation/all_docs_ref/all_refs.md index ed8b4e967..c2ac0abfc 100644 --- a/documentation/all_docs_ref/all_refs.md +++ b/documentation/all_docs_ref/all_refs.md @@ -48,12 +48,12 @@ its use requires resorting to the \myreflink{Monolithic} mode. | \myreflink{ablines} | \myreflink{append2fig} | \myreflink{blendimg!} | \myreflink{cart2pol} | \myreflink{cart2sph} | \myreflink{colorzones!} | \myreflink{cpt4dcw} | \myreflink{crop} | | \myreflink{cubeplot} | \myreflink{coastlinesproj} | \myreflink{cubeslice} | \myreflink{date2doy} | \myreflink{delrows!} | \myreflink{doy2date} | \myreflink{gadm} | \myreflink{geocoder} | | \myreflink{geodetic2enu} | \myreflink{getbyattrib} | \myreflink{gmtread} | \myreflink{gmtwrite} | \myreflink{graticules} | \myreflink{gridit} | \myreflink{gunique} | \myreflink{imagesc} | -| \myreflink{inwhichpolygon} | \myreflink{image_alpha!} | \myreflink{image_cpt!} | \myreflink{imshow} | \myreflink{ind2rgb} | \myreflink{info} | \myreflink{isnodata} | \myreflink{lelandshade} | -| \myreflink{linearfitxy} | \myreflink{magic} | \myreflink{mat2ds} | \myreflink{mat2grid} | \myreflink{mat2img} | \myreflink{mosaic} | \myreflink{ODE2ds} | \myreflink{orbits} | -| \myreflink{pca} | \myreflink{plotgrid!} | \myreflink{plotyy} \myreflink{pol2cart} | \myreflink{polygonlevels} | \myreflink{rasterzones!} | \myreflink{regiongeog} | \myreflink{rescale} | \myreflink{slicecube} | -| \myreflink{sph2cart} | \myreflink{stackgrids} | \myreflink{ter2cart} | \myreflink{theme} | \myreflink{uniqueind} | \myreflink{vecangles} | \myreflink{weather} | \myreflink{whereami} | -| \myreflink{wmsinfo} | \myreflink{wmsread} | \myreflink{wmstest} | \myreflink{worldrectgrid} | \myreflink{worldrectcoast} | \myreflink{worldrectangular} | \myreflink{xyzw2cube} | \myreflink{yeardecimal} | -| \myreflink{zonal_stats} | | | | | | | | +| \myreflink{inpolygon} | \myreflink{inwhichpolygon} | \myreflink{image_alpha!} | \myreflink{image_cpt!} | \myreflink{imshow} | \myreflink{ind2rgb} | \myreflink{info} | \myreflink{isnodata} | +| \myreflink{lelandshade} | \myreflink{linearfitxy} | \myreflink{magic} | \myreflink{mat2ds} | \myreflink{mat2grid} | \myreflink{mat2img} | \myreflink{mosaic} | \myreflink{ODE2ds} | +| \myreflink{orbits} | \myreflink{pca} | \myreflink{plotgrid!} | \myreflink{plotyy} \myreflink{pol2cart} | \myreflink{polygonlevels} | \myreflink{rasterzones!} | \myreflink{regiongeog} | \myreflink{rescale} | +| \myreflink{slicecube} | \myreflink{sph2cart} | \myreflink{stackgrids} | \myreflink{ter2cart} | \myreflink{theme} | \myreflink{uniqueind} | \myreflink{vecangles} | \myreflink{weather} | +| \myreflink{whereami} | \myreflink{wmsinfo} | \myreflink{wmsread} | \myreflink{wmstest} | \myreflink{worldrectgrid} | \myreflink{worldrectcoast} | \myreflink{worldrectangular} | \myreflink{xyzw2cube} | +| \myreflink{yeardecimal} | \myreflink{zonal_stats} | | | | | | | ## GDAL utility functions diff --git a/documentation/modules/clip.md b/documentation/modules/clip.md index 81469e4f9..2f8f315cd 100644 --- a/documentation/modules/clip.md +++ b/documentation/modules/clip.md @@ -101,6 +101,18 @@ clip!(endclip=true, frame=:same, show=true) where we activate and deactivate the clip path. Note we also draw the outline of the clip path to make it clear what is being clipped. +But although the above example shows how we can fine tune what is plotted under the clip path, and we could +have drawn more elements if whiched, it is also a bit cumbersome for simple plots. A much more straightforward +command can be done using the _nested_ clip program that is available to all plotting modules. This one-liner +produces almost the same plot. + +\begin{examplefig}{} +```julia +using GMT +plot("@tut_data.txt", fill=:red, marker=:circ, ms=2, region=(0,6,0,6), clip=[0 0; 5 1; 5 5], show=true) +``` +\end{examplefig} + See Also -------- diff --git a/documentation/modules/coast.md b/documentation/modules/coast.md index 58114eca1..fecb8648a 100644 --- a/documentation/modules/coast.md +++ b/documentation/modules/coast.md @@ -43,8 +43,8 @@ painted and no land fill is set then the land-areas will be transparent. A map p The resolution drops off by 80% between data sets. The default is **res=:auto**, which chooses to automatically select the best resolution given the chosen map scale. -- **E** or **DCW** : -- *DCW=code1,code2,...* **|** *DCW=(country=code, continent=code, pen=pen, fill=fill)*\ - Select painting country polygons from the Digital Chart of the World. This is another dataset independent of GSHHG and hence the **area** and **resolution** options do not apply. **DCW="+l"** just list the countries and their codes [plotting takes place] and **DCW="+L"** shows states/territories for Argentina, Australia, Brazil, Canada, and the US. *country* or **name=code(s)**, where **code(s)** is a one or more comma-separated countries using the 2-character ISO 3166-1 alpha-2 convention. To select a state of a country (if available), append .state, e.g, US.TX for Texas. To specify a whole continent, use **continent=code**, with continent codes AF (Africa),AN (Antarctica), AS (Asia), EU (Europe), OC (Oceania), NA (North America), or SA (South America). Use **pen=pen** (see \myreflink{Pen attributes}) to draw polygon outlines and **fill=fill** (see \myreflink{Fill color/pattern}) to fill them [default is no fill]. At least one of these must be specified unless **dump** is in effect, in which case only one **DCW** option can be given. It is also possible to specify the parameters using simple Tuples. For example: **DCW=("PT", (0.5,"red","--"), "blue")** plots the polygon *PT* with a 0.5p red dashed line and filled with blue and **DCW=:PT** uses a default pen of 0.5. **DCW=(:PT, :blue)** fills with blue. You may repeat **DCW** to give different groups of items their own *pen/fill* settings. However, since we cannot repeat a keyword, the solution to setting different groupes is to use a tuple of tuples. An example would be *DCW=((country=:PT, pen=(2,:red), fill=:blue), (country=:ES, pen=(2,:blue)) )*. If neither **proj** nor **dump** are set then we just print the **region**. +- **E** or **DCW** : -- *DCW=code1,code2,...* **|** *DCW=(country=code, continent=code, pen=pen, fill=fill, file=fname, inside=true, outside=false, adjust_r=??, , adjust_R=??, , adjust_e=??, headers=false)*\ + Select painting country polygons from the Digital Chart of the World. This is another dataset independent of GSHHG and hence the **area** and **resolution** options do not apply. **DCW="+l"** just list the countries and their codes [plotting takes place] and **DCW="+L"** shows states/territories for Argentina, Australia, Brazil, Canada, and the US. *country* or **name=code(s)**, where **code(s)** is a one or more comma-separated countries using the 2-character ISO 3166-1 alpha-2 convention. To select a state of a country (if available), append .state, e.g, US.TX for Texas. To specify a whole continent, use **continent=code**, with continent codes AF (Africa),AN (Antarctica), AS (Asia), EU (Europe), OC (Oceania), NA (North America), or SA (South America). Use **pen=pen** (see \myreflink{Pen attributes}) to draw polygon outlines and **fill=fill** (see \myreflink{Fill color/pattern}) to fill them [default is no fill]. At least one of these must be specified unless **dump** is in effect, in which case only one **DCW** option can be given. It is also possible to specify the parameters using simple Tuples. For example: **DCW=("PT", (0.5,"red","--"), "blue")** plots the polygon *PT* with a 0.5p red dashed line and filled with blue and **DCW=:PT** uses a default pen of 0.5. **DCW=(:PT, :blue)** fills with blue. You may repeat **DCW** to give different groups of items their own *pen/fill* settings. However, since we cannot repeat a keyword, the solution to setting different groupes is to use a tuple of tuples. An example would be *DCW=((country=:PT, pen=(2,:red), fill=:blue), (country=:ES, pen=(2,:blue)) )*. If neither **proj** nor **dump** are set then we just print the **region**. The **file=fname** is a new option in future GMT to let users select alternative DCW files. The **inside=true** (the default) means that data is ket _inside_ the clipping polygon. Use **outside=true** if want the reverse. **adjust_r=??** adjusts the region boundaries to be multiples of the steps indicated by _inc_ or _xinc/yinc_ or _winc/einc/sinc/ninc_. **adjust_R=??** adjusts the region boundaries adding the amounts specified by _inc_ or _xinc/yinc_ or _winc/einc/sinc/ninc_. **headers=true** place the country code in the segment headers via _-Zcode_ settings (for use with the **dump** option). - **getR** or **getregion** or **get_region** : -- *getR=code1,code2,...*\ Return the region corresponding to the code/list-of-codes passed in as argument. The code(s) are the same diff --git a/documentation/modules/grdimage.md b/documentation/modules/grdimage.md index f1b81c3aa..611724ee0 100644 --- a/documentation/modules/grdimage.md +++ b/documentation/modules/grdimage.md @@ -54,6 +54,20 @@ Optional Arguments \textinput{common_opts/use_cpt_grd} +- **clim** : -- *clim=(z_min,z_max)* **|** *clim=:zscale*\ + When doing an automatic colorization (*i.e.*, when a colormap is not provided explicitly), limit the automatic + color map to be computed between *z_min,z_max*. Grid values below *z_min* and above *z_max* will be painted + with the same color as those. Alternatively, use *clim=:zscale* to use the Interval based on IRAF’s zscale + that is an algorithm used in astronomy for finding colorbar limits of for the grid, which showcase data near the median. + +- **clip** : -- *clip="land"* **|** *clip=:ocean* **|** *clip="country_code(s)"* **|** *clip=(country="code(s)", [outside=true])* **|** *clip=xy* **|** *clip=(xy, inverse=true)*\ + Clip the image according to the selected option. First set of options do the clipping using the `coast` module. _e.,g._: + **clip="land"** (or =:land) clip outside land areas. **clip="ocean"** does the inverse. **clip="country_code(s)"** uses + one or more country codes (separated by commas) to do the clipping. If want to reverse the sense of the clipping, use the + form **clip=(country="code(s)", outside=true)**. Use **clip=(continent=code, [outside=true])** to pass the name of + continent. Pay attention that this option must be a named tuple. The second set of options make use of the `clip` module + and expect a first argument with a Mx2 matrix with the coordinates of the clipping polygon. + - **coast** : -- *coast=true* **|** *coast=(...)*\ Call the \myreflink{coast} module to overlay coastlines and/or countries. The short form *coast=true* just plots the coastlines with a black, 0.5p thickness line. To access all options available in the *coast* @@ -64,12 +78,6 @@ Optional Arguments color bar on the right side of the image using the current color map stored in the global scope. To access all options available in the *colorbar* module passe them in the named tuple (...). -- **clim** : -- *clim=(z_min,z_max)* **|** *clim=:zscale*\ - When doing an automatic colorization (*i.e.*, when a colormap is not provided explicitly), limit the automatic - color map to be computed between *z_min,z_max*. Grid values below *z_min* and above *z_max* will be painted - with the same color as those. Alternatively, use *clim=:zscale* to use the Interval based on IRAF’s zscale - that is an algorithm used in astronomy for finding colorbar limits of for the grid, which showcase data near the median. - - **equalize** : -- *equalize=true* **|** *equalize=ncolors*\ With automatic colorization, map data values to colors through the data’s cumulative distribution function (CDF), so that the colors are histogram equalized. Default (with `equalize=true`) chooses arbitrary values by a crazy @@ -156,3 +164,13 @@ using GMT grdimage("@AK_gulf_grav.nc", shade=true, coast=true, show=true) ``` \end{examplefig} + +Clip the outside of Africa from Bing mosaic. (You can try also `viz(I, clip=:land)` and `viz(I, clip=(continent=:AF, outside=true))`) + +\begin{examplefig}{} +```julia +using GMT +I = mosaic(region=(continent="AF",)); # Get a mosaic of the ~Africa region +viz(I, clip=(continent=:AF,)) # Clip outside of the African continent. +``` +\end{examplefig} diff --git a/documentation/utilities/inwhichpolygon.md b/documentation/utilities/inwhichpolygon.md index 001c2c830..8c091265d 100644 --- a/documentation/utilities/inwhichpolygon.md +++ b/documentation/utilities/inwhichpolygon.md @@ -1,25 +1,23 @@ # inwhichpolygon ```julia -inwhichpolygon(D::Vector{GMTdataset}, point::Matrix{Real}) +inwhichpolygon(D::Vector{GMTdataset}, point::Matrix{Real}; on_is_in=false) or -inwhichpolygon(D::Vector{GMTdataset}, x, y) +inwhichpolygon(D::Vector{GMTdataset}, x, y; on_is_in=false) ``` *keywords: GMT, Julia, point in polygon* 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. +Returns either an ``Int`` or a ``Vector{Int}`` depending on the number of input query points. - `D`: A Vector of \myreflink{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). - +- `on_is_in`: If `on_is_in=true` then points exactly on the border are considered inside. Default is `false`. Examples -------- @@ -31,7 +29,7 @@ using GMT 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); +ids = inwhichpolygon(points, D); # Plot the triangulation and the query points. plot(D) @@ -45,4 +43,4 @@ plot!(points, marker=:star, ms="12p", fill=:blue, show=true) See Also -------- -\myreflink{getbyattrib}, \myreflink{plot}, \myreflink{triplot} +\myreflink{inpolygon}, \myreflink{getbyattrib}, \myreflink{plot}, \myreflink{triplot}