Package tiler. June 9, 2018

Similar documents
Package fastdummies. January 8, 2018

Package canvasxpress

Package cattonum. R topics documented: May 2, Type Package Version Title Encode Categorical Features

Package spark. July 21, 2017

Package ECctmc. May 1, 2018

Package geojsonsf. R topics documented: January 11, Type Package Title GeoJSON to Simple Feature Converter Version 1.3.

Package messaging. May 27, 2018

Package rosm. April 8, 2017

Package tabulizer. June 7, 2018

Package validara. October 19, 2017

Package nngeo. September 29, 2018

Package gggenes. R topics documented: November 7, Title Draw Gene Arrow Maps in 'ggplot2' Version 0.3.2

Package sigmanet. April 23, 2018

Package htmlwidgets. July 10, 2017

Package ggimage. R topics documented: November 1, Title Use Image in 'ggplot2' Version 0.0.7

Package gfcanalysis. August 29, 2016

Package datasets.load

Package kdtools. April 26, 2018

Package jdx. R topics documented: January 9, Type Package Title 'Java' Data Exchange for 'R' and 'rjava'

Package opencage. January 16, 2018

Package semver. January 6, 2017

Package leaflet.minicharts

Package ggimage. R topics documented: December 5, Title Use Image in 'ggplot2' Version 0.1.0

Package barcoder. October 26, 2018

Package docxtools. July 6, 2018

Package rbgm. May 18, 2018

Package rcmdcheck. R topics documented: November 10, 2018

Package knitrprogressbar

Package xroi. February 13, 2019

Package rprojroot. January 3, Title Finding Files in Project Subdirectories Version 1.3-2

Package jpmesh. December 4, 2017

Package sessioninfo. June 21, 2017

Package htmlwidgets. February 25, 2016

Package qualmap. R topics documented: September 12, Type Package

Package geogrid. August 19, 2018

Package bisect. April 16, 2018

Package goodpractice

Package sfdct. August 29, 2017

Package crossword.r. January 19, 2018

Package memery. February 13, 2018

Package d3heatmap. February 1, 2018

Package clipr. June 23, 2018

Package githubinstall

Package pdfsearch. July 10, 2018

Package shiny.semantic

Package rollply. R topics documented: August 29, Title Moving-Window Add-on for 'plyr' Version 0.5.0

Package projector. February 27, 2018

Package robotstxt. November 12, 2017

Package facerec. May 14, 2018

Package spelling. December 18, 2017

Package postgistools

Package waver. January 29, 2018

Package profvis. R topics documented:

Package nmslibr. April 14, 2018

Package editdata. October 7, 2017

Package SEMrushR. November 3, 2018

Package mapr. April 11, 2017

Package shinytest. May 7, 2018

Package farver. November 20, 2018

Package pairsd3. R topics documented: August 29, Title D3 Scatterplot Matrices Version 0.1.0

Package repec. August 31, 2018

Package datapasta. January 24, 2018

Package wdman. January 23, 2017

Package readxl. April 18, 2017

Package humanize. R topics documented: April 4, Version Title Create Values for Human Consumption

Package internetarchive

Package gtrendsr. August 4, 2018

Package cancensus. February 4, 2018

Package rsppfp. November 20, 2018

Package nlgeocoder. October 8, 2018

Package mapr. March 21, 2018

Package utf8. May 24, 2018

Package smoothr. April 4, 2018

Package slickr. March 6, 2018

Package triebeard. August 29, 2016

Package deckgl. November 19, 2018

Package rpostgislt. March 2, 2018

Package callr. August 29, 2016

Package ezknitr. September 16, 2016

Package modules. July 22, 2017

Package shinyfeedback

Package data.world. April 5, 2018

Package angstroms. May 1, 2017

Package geoops. March 19, 2018

Package gtrendsr. October 19, 2017

Package loggit. April 9, 2018

Package colourpicker

Package carbonate. R topics documented: October 14, 2018

Package censusr. R topics documented: June 14, Type Package Title Collect Data from the Census API Version 0.0.

Package rnaturalearth

Package meme. November 2, 2017

Package essurvey. August 23, 2018

Package patentsview. July 12, 2017

Package WordR. September 7, 2017

Package splithalf. March 17, 2018

Package gifti. February 1, 2018

Package mapedit. R topics documented: March 2, Title Interactive Editing of Spatial Data in R

Package calpassapi. August 25, 2018

Package meme. December 6, 2017

Package ssh. June 4, 2018

Transcription:

Version 0.2.0 Package tiler June 9, 2018 Title Create Geographic and Non-Geographic Map Tiles Creates geographic map tiles from geospatial map files or nongeographic map tiles from simple image files. This package provides a tile generator function for creating map tile sets for use with packages such as 'leaflet'. In addition to generating map tiles based on a common raster layer source, it also handles the nongeographic edge case, producing map tiles from arbitrary images. These map tiles, which have a non-geographic, simple coordinate reference system (CRS), can also be used with 'leaflet' when applying the simple CRS option. Map tiles can be created from an input file with any of the following extensions: tif, grd and nc for spatial maps and png, jpg and bmp for basic images. This package requires 'Python' and the 'gdal' library for 'Python'. 'Windows' users are recommended to install 'OS- Geo4W' (<https://trac.osgeo.org/osgeo4w/>) as an easy way to obtain the required 'gdal' support for 'Python'. License MIT + file LICENSE Encoding UTF-8 LazyData true ByteCompile true URL https://github.com/leonawicz/tiler BugReports https://github.com/leonawicz/tiler/issues SystemRequirements Python (>= 2.7), python-gdal library (For Windows, gdal installed via OSGeo4W <https://trac.osgeo.org/osgeo4w/> recommended) clipboard Suggests testthat, knitr, rmarkdown, lintr, covr, jpeg, bmp Imports sp, rgdal, raster, png VignetteBuilder knitr RoxygenNote 6.0.1 NeedsCompilation no 1

2 tile Author Matthew Leonawicz [aut, cre], Scenarios Network for Alaska and Arctic Planning [cph, fnd] Maintainer Matthew Leonawicz <mfleonawicz@alaska.edu> Repository CRAN Date/Publication 2018-06-09 19:48:52 UTC R topics documented: tile.............................................. 2 tiler............................................. 4 tiler_options......................................... 5 tile_viewer......................................... 6 view_tiles.......................................... 7 Index 8 tile Create map tiles Create geographic and non-geographic map tiles from a file. Usage tile(file, tiles, zoom, crs = NULL, format = c("xyz", "tms"), resume = FALSE, viewer = TRUE, georef = TRUE,...) Arguments file tiles zoom crs format resume viewer georef character, input file. character, output directory for generated tiles. character, zoom levels. Example format: "3-7". See details. character, Proj4 string. Use this to force set the CRS of a loaded raster object from file in cases where the CRS is missing but known, to avoid defaulting to non-geographic tiling. character, XYZ or TMS tile format. See details. logical, only generate missing tiles. logical, also create preview.html adjacent to tiles directory for previewing tiles in the browser using Leaflet. logical, for non-geographic tiles only. If viewer = TRUE, then the Leaflet widget in preview.html will add map markers with coordinate labels on mouse click to assist with georeferencing of non-geographic tiles.

tile 3... additional arguments for projected maps: reprojection method or any arguments to raster::rgb, e.g. col and colna. See details. Other additional arguments lng and lat can also be passed to the tile previewer. See tile_viewer for details. This function supports both geographic and non-geographic tile generation. When file is a simple image file such as png, tile generates non-geographic, simple CRS tiles. Files that can be loaded by the raster package yield geographic tiles, as long as file has projection information. If the raster object s proj4 string is NA, it falls back on non-geographic tile generation and a warning is thrown. Choice of appropriate zoom levels for non-geographic image files may depend on the size of the image. A zoom value may be partially ignored for image files under certain conditions. For instance using the example map.png below, when passing strictly zoom = n where n is less than 3, this still generates tiles for zoom n up through 3. Supported file types: Supported simple CRS/non-geographic image file types include png, jpg and bmp. For projected map data, supported file types include three types readable by the raster package: grd, tif, and nc (requires ncdf4). Other currently unsupported file types passed to file throw an error. Raster file inputs: If a map file loadable by raster is a single-layer raster object, tile coloring is applied. To override default coloring of data and nodata pixels, pass the additional arguments col and colna to... Multi-layer raster objects are rejected with an error message. The only exception is a three- or four-band raster, which is assumed to represent red, green, blue and alpha channels, respectively. In this case, processing will continue but coloring arguments are ignored as unnecessary. Prior to tiling, a geographically-projected raster layer is reprojected to EPSG:4326 only if it has some other projection. Otherwise no reprojection is needed. The only reprojection argument available through... is method, which can be "bilinear" (default) or"ngb". If complete control over reprojection is required, this should be done prior to passing the rasterized file to the tile function. Then no reprojection is performed by tile. When file consists of RGB or RGBA bands, method is ignored if provided and reprojection uses nearest neighbor. It is recommended to avoid using a projected 4-band RGBA raster file or gdal2tiles. However, the alpha channel appears to be ignored anyway. gdal2tiles gives an internal warning. Instead, create your RGBA raster file in unprojected form and it should seamlessly pass through to gdal2tiles without any issues. Three-band RGB raster files appear are unaffected by reprojection. The alpha channel appears to be completely ignored in the tiling process anyway, so it is fine to just use RGB rasters. Tiles and Leaflet: gdal2tiles generates TMS tiles, but XYZ are available and the default. Tile format only applies to geographic maps. All simple image-based tiles are XYZ format. See details. This function is supported by three different versions of gdal2tiles. There is the standard version, which generates geospatial tiles in TMS format. One alternative generates tiles in XYZ

4 tiler Value See Also format. This is the default for tile. It may be more familiar to R users working with the leaflet package. There is no real benefit of using one version over the other for tiling spatial maps. If you set format = "tms" you may need to do similarly in your raw Leaflet code or your leaflet R code for tiles to arrange and display with the proper orientation. The third version of gdal2tiles handles basic image files like a matrix of rows and columns, using a simple Cartesian coordinate system based on pixel dimensions of the image file. See the Leaflet JS library and leaflet package documentation for working with custom tiles in Leaflet. nothing is returned but tiles are written to disk. view_tiles, tile_viewer Examples # non-geographic/simple CRS x <- system.file("maps/map.png", package = "tiler") tiles <- file.path(tempdir(), "tiles") tile(x, tiles, "2-3") # projected map x <- system.file("maps/map_wgs84.tif", package = "tiler") tile(x, tiles, 0) tiler tiler: Create map tiles from R The tiler package creates geographic map tiles from geospatial map files or non-geographic map tiles from simple image files. This package provides a tile generator function for creating map tile sets for use with packages such as leaflet. In addition to generating map tiles based on a common raster layer source, it also handles the non-geographic edge case, producing map tiles from arbitrary images. These map tiles, which have a non-geographic simple coordinate reference system (CRS), can also be used with leaflet when applying the simple CRS option. Map tiles can be created from an input file with any of the following extensions: tif, grd and nc for spatial maps and png, jpg and bmp for basic images.

tiler_options 5 This package requires Python and the gdal library for Python. Windows users are recommended to install https://trac.osgeo.org/osgeo4w/ as an easy way to obtain the required gdal support for Python in Windows. tiler_options Options Usage Options for tiler package. tiler_options(...) Arguments Value... a list of options. On Windows systems, if the system paths for python.exe and OSGeo4W.dat are not added to the system path, they must be provided by the user after loading the package. It is recommended to add these to the system path so they do not need to be specified for every R session. They may be installed to different locations on different Windows systems. Currently, tiler will make a single attempt during package load to look for OSGeo4W.bat in one location: C:/Program Files/QGIS 3.0/OSGeo4W.bat. If it is not found at this exact location and it is not on the system path, it will be unavailable to tile unless the user specifies the path in tiler_options. Finding the installation is not the responsibility of tiler. Best practice is to know these paths on Windows and proactively add them to the system path so that they are automatically available to programs like R. As long as OSGeo4W.bat is unavailable, tile will proceed as it would on other systems such as Linux, by assuming GDAL is installed and accessible to Python on the system, regardless of OSGeo installations. The recommended way to have GDAL available to Python in Windows is to install OSGeo4W. This is commonly installed along with QGIS. This being the common method for having these system requirements available on Windows is the reason the tiler package bothers to attempt using OSGeo4W.bat first. None of this applies to other systems. As long as the system requirements, Python and GDAL, are installed, then tile should generate tiles without getting or setting any tiler_options. The function prints all set options if called with no arguments. When setting options, nothing is returned.

6 tile_viewer Examples tiler_options() tiler_options(python = "C:/Python/Python36/python.exe", osgeo4w = "C:/Program Files/QGIS 3.0/OSGeo4W.bat") tile_viewer Create an HTML tile preview Create an HTML file that displays a tile preview using Leaflet. Usage tile_viewer(tiles, zoom, width = NULL, height = NULL, georef = TRUE,...) Arguments tiles character, directory where tiles are stored. zoom character, zoom levels full range. Example format: "3-7". width height georef NULL (default) for geospatial map tiles. The original image width in pixels for non-geographic, simple CRS tiles. NULL (default) for geospatial map tiles. The original image height in pixels for non-geographic, simple CRS tiles. logical, for non-geographic tiles only. If viewer = TRUE, then the Leaflet widget in preview.html will add map markers with coordinate labels on mouse click to assist with georeferencing of non-geographic tiles.... additional optional arguments include format = "tms" if necessary, and lng and lat for setting the view longitude and latitude. These three arguments only apply to geographic tiles. Viewer centering is 0, 0 by default. This function creates a file preview.html adjacent to the tiles base directory. When loaded in the browser, this file displays map tiles from the adjacent folder. For example, if tiles are stored in project/tiles, this function creates project/preview.html. By default, tile creates this file. The only reasons to call tile_viewer directly after producing map tiles are: (1) if viewer = FALSE was set in the call to tile, (2) if tile was called multiple times, e.g., for different batches of zoom levels, and thus the most recent call did not use the full zoom range, or (3) preview.html was deleted for some other reason. If calling this function directly, ensure that the min and max zoom, and original image pixel dimensions if applicable, match the generated tiles. These arguments are passed to tile_viewer automatically when called within tile, based on the source file provided to tile.

view_tiles 7 Value nothing is returned, but a file is written to disk. See Also view_tiles, tile Examples tile_viewer(file.path(tempdir(), "tiles"), "3-7") # requires an existing tile set view_tiles View map tiles with Leaflet View map tiles in the browser using leaflet. Usage view_tiles(tiles) Arguments tiles character, directory where tiles are stored. Value This function opens preview.html in a web browser. This file displays map tiles in a Leaflet widget. The file is created when tile is called to generate the map tiles, unless viewer = FALSE. Alternatively, it is created (or re-created) subsequent to tile creation using tile_viewer. See Also nothing is returned, but the default browser is launched. tile_viewer, tile Examples # launches browser; requires an existing tile set ## Not run: view_tiles(file.path(tempdir(), "tiles"))

Index tile, 2, 7 tile_viewer, 3, 4, 6, 7 tiler, 4 tiler-package (tiler), 4 tiler_options, 5 view_tiles, 4, 7, 7 8