diff --git a/DESCRIPTION b/DESCRIPTION index ad606306956ae9ba51162b987f8f0a8e9a7a8db3..6119e508b663e0d00b45e2eb801b4f6dc12dea65 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -31,6 +31,8 @@ Imports: stats, plyr, ncdf4, + rgdal, + sp, multiApply (>= 2.0.0) Suggests: easyVerification, diff --git a/NAMESPACE b/NAMESPACE index 627bf51ce445554a9aa98ee491eb9163808fc2dc..34b6b1a527b4220428d912ef9be98ef638251cc3 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -65,6 +65,8 @@ importFrom(grDevices,rgb) importFrom(grDevices,svg) importFrom(grDevices,tiff) importFrom(plyr,take) +importFrom(rgdal,readOGR) +importFrom(sp,spTransform) importFrom(stats,acf) importFrom(stats,confint) importFrom(stats,cor) diff --git a/R/PlotEquiMap.R b/R/PlotEquiMap.R index 37847dcc40166713a346b3859c38a75f85699fcc..cd9858dbc706ad47a198d52d6a099a7e81b813c1 100644 --- a/R/PlotEquiMap.R +++ b/R/PlotEquiMap.R @@ -148,6 +148,12 @@ #' the corresponding device. #'@param res Resolution of the device (file or window) to plot in. See #' ?Devices and the creator function of the corresponding device. +#'@param input_shapefile A character string describing the pathway to your +#' shapefile of the region of interest. +#'@param lwd_shapefile Line width of the shapefile boundary lines. +#' Defaults to 2. +#'@param col_shapefile Colour of the shapefile boundary lines. +#' Defaults to 'black'. #'@param \dots Arguments to be passed to the method. Only accepts the following #' graphical parameters:\cr #' adj ann ask bg bty cex.sub cin col.axis col.lab col.main col.sub cra crt @@ -206,6 +212,8 @@ #'@import graphics GEOmap geomapdata maps #'@importFrom grDevices dev.cur dev.new dev.off gray #'@importFrom stats cor +#'@importFrom rgdal readOGR +#'@importFrom sp spTransform #'@export PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, toptitle = NULL, sizetit = NULL, units = NULL, @@ -234,7 +242,8 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, margin_scale = rep(1, 4), title_scale = 1, numbfig = NULL, fileout = NULL, width = 8, height = 5, size_units = 'in', - res = 100, ...) { + res = 100, input_shapefile = NULL, lwd_shapefile = 2, + col_shapefile = 'black', ...) { # Process the user graphical parameters that may be passed in the call ## Graphical parameters to exclude excludedArgs <- c("cex", "cex.axis", "cex.lab", "cex.main", "col", "din", "fig", "fin", "lab", "las", "lty", "lwd", "mai", "mar", "mgp", "new", "oma", "ps", "tck") @@ -603,6 +612,13 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, } } + # Check input_shapefile + if (!is.null(input_shapefile)) { + if (!is.character(input_shapefile)) { + input_shapefile <- NULL + warning("The 'input_shapefile' must be character string.") + } + } #library(GEOmap) #library(geomapdata) #library(maps) @@ -797,6 +813,27 @@ PlotEquiMap <- function(var, lon, lat, varu = NULL, varv = NULL, counter <- counter + 1 } } + + # + # shapefile + # ~~~~~~~~~~ + # + if (!is.null(input_shapefile)) { + if (!is.numeric(lwd_shapefile)) { + lwd_shapefile = 2 + warning(" Parameter 'lwd_shapefile' must be numeric, it has been set to 2.") + } + # plot the boundary of the region of interest from shapefile + # Read the shapefile + shp1 <- readOGR(dsn = input_shapefile, layer = 'RDD_ETRS89') + warning("The input_shapefile was read with the layer named RDD_ETRS89.") + s1 <- spTransform(shp1, CRS("+proj=longlat")) + warning("The input_shapefile was transformed with CRS: +proj=longlat.") + roi <- SpatialPolygons2map(s1) + # Plot the region of interest + map(roi, interior = FALSE, add = TRUE, lwd = lwd_shapefile, col = col_shapefile) + } + # # PlotWind # ~~~~~~~~~~ diff --git a/data/shapefile_sample/RDD_ETRS89.dbf b/data/shapefile_sample/RDD_ETRS89.dbf new file mode 100644 index 0000000000000000000000000000000000000000..685e26bf8024facb258d3204eb66820f21393e59 Binary files /dev/null and b/data/shapefile_sample/RDD_ETRS89.dbf differ diff --git a/data/shapefile_sample/RDD_ETRS89.prj b/data/shapefile_sample/RDD_ETRS89.prj new file mode 100644 index 0000000000000000000000000000000000000000..f2bf688c9ca2ebddc29739980ff80223cf5ff443 --- /dev/null +++ b/data/shapefile_sample/RDD_ETRS89.prj @@ -0,0 +1 @@ +PROJCS["Datum_73_Hayford_Gauss_IGeoE",GEOGCS["GCS_Datum_73",DATUM["D_Datum_73",SPHEROID["International_1924",6378388.0,297.0]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Transverse_Mercator"],PARAMETER["False_Easting",200180.598],PARAMETER["False_Northing",299913.01],PARAMETER["Central_Meridian",-8.131906111111112],PARAMETER["Scale_Factor",1.0],PARAMETER["Latitude_Of_Origin",39.66666666666666],UNIT["Meter",1.0]] \ No newline at end of file diff --git a/data/shapefile_sample/RDD_ETRS89.sbn b/data/shapefile_sample/RDD_ETRS89.sbn new file mode 100644 index 0000000000000000000000000000000000000000..191fcd71c057ca7d19043b035029d56803a7dfaf Binary files /dev/null and b/data/shapefile_sample/RDD_ETRS89.sbn differ diff --git a/data/shapefile_sample/RDD_ETRS89.sbx b/data/shapefile_sample/RDD_ETRS89.sbx new file mode 100644 index 0000000000000000000000000000000000000000..7aa46006b1499ff60cb275c65e99880bf43991f1 Binary files /dev/null and b/data/shapefile_sample/RDD_ETRS89.sbx differ diff --git a/data/shapefile_sample/RDD_ETRS89.shp b/data/shapefile_sample/RDD_ETRS89.shp new file mode 100644 index 0000000000000000000000000000000000000000..f280ab7de7191ad8fec5941f1474ef2e95150830 Binary files /dev/null and b/data/shapefile_sample/RDD_ETRS89.shp differ diff --git a/data/shapefile_sample/RDD_ETRS89.shp.xml b/data/shapefile_sample/RDD_ETRS89.shp.xml new file mode 100644 index 0000000000000000000000000000000000000000..89aba32a7f7a9151b74b13afee69cd9d29196a69 --- /dev/null +++ b/data/shapefile_sample/RDD_ETRS89.shp.xml @@ -0,0 +1,2 @@ + +2014110309591000FALSE20110204111122002011020411112200CopyFeatures \\oceanus\e$\Ortos\SIG_IVDP.gdb\FreguesiasRDD_polygon "Database Connections\sdeAdmin@OCEANUS.sde\sde.SDE.FreguesiasRDD_polygon" # 0 0 0CopyFeatures "Database Connections\ACanha@oceanus.sde\sde.SDE.FreguesiasRDD" "C:\Documents and Settings\Antonio Canha\Desktop\ESRI\sde_SDE_FreguesiasRDD.shp" # 0 0 0CopyFeatures "C:\Documents and Settings\cmatias\Desktop\ESRI\sde_SDE_FreguesiasRDD.shp" "C:\Documents and Settings\cmatias\Desktop\IVDP - Instituto dos Vinhos do Douro e do Porto\Dados.gdb\sde_SDE_FreguesiasRDD" # 0 0 0CalculateField "Database Connections\Connection to geodouro.sde\IVDP_SDE.SDE.FreguesiasRDD" Dicofre Left( [Dicofre], 6) VB #sde_SDE_FreguesiasRDD002Server=PROMETEU; Service=5151; Database=IVDP_SDE; User=sde; Version=sde.DEFAULTArcSDE ConnectionProjectedGCS_Datum_73Datum_73_Hayford_Gauss_IGeoE<ProjectedCoordinateSystem xsi:type='typens:ProjectedCoordinateSystem' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xmlns:xs='http://www.w3.org/2001/XMLSchema' xmlns:typens='http://www.esri.com/schemas/ArcGIS/10.0'><WKT>PROJCS[&quot;Datum_73_Hayford_Gauss_IGeoE&quot;,GEOGCS[&quot;GCS_Datum_73&quot;,DATUM[&quot;D_Datum_73&quot;,SPHEROID[&quot;International_1924&quot;,6378388.0,297.0]],PRIMEM[&quot;Greenwich&quot;,0.0],UNIT[&quot;Degree&quot;,0.0174532925199433]],PROJECTION[&quot;Transverse_Mercator&quot;],PARAMETER[&quot;False_Easting&quot;,200180.598],PARAMETER[&quot;False_Northing&quot;,299913.01],PARAMETER[&quot;Central_Meridian&quot;,-8.131906111111112],PARAMETER[&quot;Scale_Factor&quot;,1.0],PARAMETER[&quot;Latitude_Of_Origin&quot;,39.66666666666666],UNIT[&quot;Meter&quot;,1.0],AUTHORITY[&quot;ESRI&quot;,102160]]</WKT><XOrigin>-5423200</XOrigin><YOrigin>-14095100</YOrigin><XYScale>10000</XYScale><ZOrigin>-100000</ZOrigin><ZScale>10000</ZScale><MOrigin>-100000</MOrigin><MScale>10000</MScale><XYTolerance>0.001</XYTolerance><ZTolerance>0.001</ZTolerance><MTolerance>0.001</MTolerance><HighPrecision>true</HighPrecision><WKID>102160</WKID></ProjectedCoordinateSystem>1.0Microsoft Windows XP Version 5.1 (Build 2600) Service Pack 3; ESRI ArcCatalog 9.3.1.3000ptREQUIRED: A brief narrative summary of the data set.REQUIRED: A summary of the intentions with which the data set was developed.REQUIRED: The name of an organization or individual that developed the data set.REQUIRED: The date when the data set is published or otherwise made available for release.sde_SDE_FreguesiasRDDsde_SDE_FreguesiasRDDvector digital data\\RSCAD03\C$\Documents and Settings\Antonio Canha\Desktop\ESRI\sde_SDE_FreguesiasRDD.shpREQUIRED: The basis on which the time period of content information is determined.REQUIRED: The year (and optionally month, or month and day) for which the data set corresponds to the ground.REQUIRED: The state of the data set.REQUIRED: The frequency with which changes and additions are made to the data set after the initial data set is completed.REQUIRED: Western-most coordinate of the limit of coverage expressed in longitude.REQUIRED: Eastern-most coordinate of the limit of coverage expressed in longitude.REQUIRED: Northern-most coordinate of the limit of coverage expressed in latitude.REQUIRED: Southern-most coordinate of the limit of coverage expressed in latitude.REQUIRED: Reference to a formally registered thesaurus or a similar authoritative source of theme keywords.REQUIRED: Common-use word or phrase used to describe the subject of the data set.REQUIRED: Restrictions and legal prerequisites for accessing the data set.REQUIRED: Restrictions and legal prerequisites for using the data set after access is granted.ShapefileMicrosoft Windows XP Version 5.1 (Build 2600) Service Pack 3; ESRI ArcGIS 10.0.0.2414sde_SDE_FreguesiasRDD002ptFGDC Content Standards for Digital Geospatial MetadataFGDC-STD-001-1998local timeREQUIRED: The person responsible for the metadata information.REQUIRED: The organization responsible for the metadata information.REQUIRED: The mailing and/or physical address for the organization or individual.REQUIRED: The city of the address.REQUIRED: The state or province of the address.REQUIRED: The ZIP or other postal code of the address.REQUIRED: The telephone number by which individuals can speak to the organization or individual.20110201ISO 19115 Geographic Information - MetadataDIS_ESRI1.0datasetDownloadable Data0,0000,000002file://\\RSCAD03\C$\Documents and Settings\Antonio Canha\Desktop\ESRI\sde_SDE_FreguesiasRDD.shpLocal Area Network0,000ShapefileFile Geodatabase Feature ClassVectorSimple4FALSE0TRUETRUEGCS_Datum_73Datum_73_Hayford_Gauss_IGeoEcoordinate pairmeters0.0000000.000000D_Datum_73International_19246378388.000000297.000000Explicit elevation coordinate included with horizontal coordinates0.000100Datum_73_Hayford_Gauss_IGeoEESRI10.0.000sde_SDE_FreguesiasRDDFeature Class0OBJECTIDOBJECTIDOID400Internal feature number.ESRISequential unique whole numbers that are automatically generated.IDIDDouble800SUB_REGIÃOSUB_REGIÃOString5000ÁREAÁREADouble800PERIMETROPERIMETRODouble800SECÇÃOSECÇÃOString5000SECTORSECTORString5000FreguesiaFreguesiaString20000ConcelhoConcelhoString20000DistritoDistritoString20000DicofreDicofreString5000OBSERVAÇÕEOBSERVAÇÕEString20000ID1ID1Double800ShapeShapeGeometry000Feature geometry.ESRICoordinates defining the features.Shape_LengthShape_LengthDouble800Length of feature in internal units.ESRIPositive real numbers that are automatically generated.Shape_areaShape_AreaDouble8Area of feature in internal units squared.ESRIPositive real numbers that are automatically generated.0020110204 diff --git a/data/shapefile_sample/RDD_ETRS89.shx b/data/shapefile_sample/RDD_ETRS89.shx new file mode 100644 index 0000000000000000000000000000000000000000..c786c6fb851414c63d276cf094741793b9fa8a4e Binary files /dev/null and b/data/shapefile_sample/RDD_ETRS89.shx differ diff --git a/man/PlotEquiMap.Rd b/man/PlotEquiMap.Rd index cf45ead4b3555ba1417ebcc18d7b01140550b11c..86dcc40529907c7f569dda9b8c0fb21450783ef4 100644 --- a/man/PlotEquiMap.Rd +++ b/man/PlotEquiMap.Rd @@ -22,7 +22,7 @@ PlotEquiMap(var, lon, lat, varu = NULL, varv = NULL, toptitle = NULL, bar_extra_margin = rep(0, 4), boxlim = NULL, boxcol = "purple2", boxlwd = 5, margin_scale = rep(1, 4), title_scale = 1, numbfig = NULL, fileout = NULL, width = 8, height = 5, size_units = "in", res = 100, - ...) + input_shapefile = NULL, lwd_shapefile = 2, col_shapefile = "black", ...) } \arguments{ \item{var}{Array with the values at each cell of a grid on a regular @@ -212,6 +212,15 @@ the corresponding device.} \item{res}{Resolution of the device (file or window) to plot in. See ?Devices and the creator function of the corresponding device.} +\item{input_shapefile}{A character string describing the pathway to your +shapefile of the region of interest.} + +\item{lwd_shapefile}{Line width of the shapefile boundary lines. +Defaults to 2.} + +\item{col_shapefile}{Colour of the shapefile boundary lines. +Defaults to 'black'.} + \item{\dots}{Arguments to be passed to the method. Only accepts the following graphical parameters:\cr adj ann ask bg bty cex.sub cin col.axis col.lab col.main col.sub cra crt