Giter Club home page Giter Club logo

maptools's Introduction

CRAN Task View: Mapping tools and services


Maintainer: Contact: Jeff Hollister, Scott Chamberlain, hollister.jeff at epa.gov Karthik Ram, Hadley Wickham, Ben
Marwick, Cory Nissen


This task view contains information about mapping and visualizing spatial data in R. The base version of R does not ship with many tools for mapping spatial data. Thankfully, there are an increasingly large number of tools for doing so, both with just R or javascript libraries. A list of available packages and functions is presented below, grouped by the type of activity. If you have any comments or suggestions for additions or improvements for this taskview, go to Github and submit an issue, or make some changes and submit a pull request. If you can't contribute on Github, send Jeff an email. If you have an issue with one of the packages discussed below, please contact the maintainer of that package. This task view is focused on mapping spatial data and less so on the foundations of working with spatial data in R. That material is covered in detail in the Spatial Task View. There is some overlap between the two task views, but an effort has been made to reduce redundancy so that these task views compliment one another.

Mapping tools in R

Visualization

  • cartodb: CartoDB R client. Not on CRAN, and hasn't been active for a while. Source on Github
  • cartographer: Interactive maps in R using d3-carto-map. Source on Github
  • ggmap: Visualization of spatial data and models on top of Google Maps, OpenStreetMaps, Stamen Maps, or CloudMade Maps using ggplot2. Source on Github
  • leaflet: Client for the JavaScript library Leaflet.js. Uses htmlwidgets to provide structure for output. Integrated with R Console, RStudio, and R Markdown v 2. Can include interactive maps with markdown documents as well as with shiny apps. Source on Github
  • leafletR: Another client for the JavaScript library Leaflet.js. Basic mapping functionality to combine vector data and online map tiles from different sources. Source on Github
  • mapview: This package provides wrappers to the leaflet package that simplifies the creation of maps. Stated purpose of the package is to facilitate interactive viewing of spatial data in R. Source on Github.
  • micromap: This group of functions simplifies the creation of linked micromap plots, and uses ggplot2 plotting framework. Source on Github.
  • OpenStreetMap: An R client for fetching raster images via the Open Street Maps API.
  • plotGoogleMaps: This package provides a interactive plot device for handling the geographic data for web browsers. It is designed for the automatic creation of web maps as a combination of users' data and Google Maps layers.
  • quickmpar: Quick visualization of sp and raster objects. Provides basic interactivity including zooming and panning as well as identifying features. Source on Github
  • rasterVis: Package for enhanced visualization of raster data. Source on Github
  • Rgooglemaps: Query Google static maps, and use the map as a background image to overlay plots within R. Source on Github
  • rMaps: A general purpose wrapper around main Javascript mapping libraries, including Leaflet, Datamaps, and Crosslet. Source on Github
  • sp: Core spatial package in R with basic spatial data manipulation methods. Most spatial analysis packages reuse the classes and methods provided by sp. Plotting capability in sp is provided through plot methods. More advanced plotting based on lattice. Source on GitHub
  • tmap: Package provides an approach to build thematic maps (e.g. chloropleth or bubble maps). Utilizes a grammar of graphics syntax. Source on GitHub

Projecting Data

Coordinates for spatial data can come in many different flavors with different units, datum, projections, and more. Many of the tools will visualize your data regardless of the native coordinate reference system; however, most (all?) of the javascript libraries assume some flavor of latitude-longitude, thus if your data are projected they need to be transformed back to geographic coordinates prior to mapping. For most mapping and visualization efforts unprojected data (often displayed in Web Mercator/EPSG::3857) is fine; however, if accurate area, length, or distance measurements are required through interacting with the map, then projections need to be considered. A discussion of projections and coordinate systems is beyond the scope of this task view. To learn more a good starting place is NCEAS' Overview of Coordinate Reference Systems in R. This more general discussion of projection from the USGS is also good.

Once you know that you need to transform you data there are several options:

  • sp: The function spTransform (and methods in rgdal) is the workhorse function for spatial transformations of vector data and it uses PROJ.4 arguments to specify the transformations. Accepted inputs are provided by the spTransform methods in rgdal. Source for sp on GitHub. Source for rgdal on R-Forge.
  • mapproj: This package provides a function to convert two vectors representing longitude (x) and latitude (y) to projected coordinates.
  • PBSmapping: The function convUL will transform coordinates between Universal Transverse Mercator (UTM) and longitude-latitude. A data frame with a projection attribute is required input. Source on Google Code

Geocoding

Geocoding is the process of converting address or place name information into geographic coordinates. Most of these have somewhat restricted Terms of Service(TOS). Be sure to read those carefully prior to use. Links for the TOS are provided.

Map Data

There are *many* possible sources and formats of data to use as base layers, so this list will most certainly be incomplete. Details for reading and writing most types of spatial data are already included in the Analysis of Spatial Data Task View, thus this list will focus on additional sources or features not discussed in that task view.

  • geojsonio: Provides utility for working with geojson data in R. Includes functions to convert sp objects, lists, and character to geojson format.
  • geonames: functions for working with geonames, a geographical database that covers all countries and contains over eight million place names
  • maps: Collection of coarse scaled for the US, some European countries, and a world map. Stored as `map` objects and various other geographic datasets. Location information in decimal degrees. Needs conversion to work with visualization from sp, ggmap, etc. Code for projections and additional maps in packages mapproj mapdata.
  • openadds: An R client for Openaddresses. The Openaddresses data comes in a variety of formats and this package provides common interface to simplify working with it in R. Source on Github
  • osmar: Package for interacting with the Open Street Map API in R. Functions for converting an open street map object into sp or igraph objects. Source on R-Forge.
  • prism: Accesses climate data from PRSIM. Also provides some basic plotting and mapping functions.
  • rworldmap: Set of functions to create country based world maps. Allows for joining of user specified data and can display chloropleth, gridded, bubble plot, bar charts, or pie charts. Data stored as `sp` objects. Source on Google Code.
  • tigris: Access US Census TIGER shapefiles directly in R. This package is currently in active development.
  • USAboundaries: provides spatial objects with the boundaries of states or counties in the United States of America from 1629 to 2000. It provides data from the Atlas of Historical County Boundaries.
  • UScensus2010: Functions to facilitate accessing data from the 2010 US Census using a suite of packages. Includes spatial data for census geographies (e.g. tracts, blocks, block groups, etc.). This packages is the third in a series of related package suites: UScensus1990blkgrp and UScensus2000.

CRAN packages:

Related links:

maptools's People

Contributors

benmarwick avatar jhollist avatar karthik avatar sckott avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

maptools's Issues

Workflow

@karthik Do you want to use the workflow i have for webtechnologies? no worries if not, I think you copied an older version of the makefile+other parts from webtech. I can set it up here if you want

geonames

Geonames seems like a relevant data source: 'an open-source geographical database, which you can download, that contains information on many types of features, in various languages, has attribute data (such as elevation) and comes with lat/long coordinates.' There is an R package geonames

By the way, did you write the tools.ctv file by hand? Or in some other format first and then process it to get all those tags? I'm asking because I've written a ctv in markdown and am looking for some script to convert it to the regular ctv format. Thanks.

Sources of map data

  • maps: recommended package, but data is from 2013, so is quite out of date.
  • rworldmap, rworldxtra: Data from Natural Earth.
  • osmar: vector data from open street map
  • UScensus2010: US census data

geocoding

ggmap::geocode # Google maps
geocodeHERE # Nokia HERE

Converting raster to PPP using as.ppp() requires maptools, which is no longer on CRAN

I am attempting to import a bitmap image into R, rasterize it, and calculate the area of discrete regions in the image using spatstats. Importing the bitmap into R and converting it to a raster isn't a problem:

library(bmp)
library(raster)
bmp_01 = read.bmp("20231031_110019.bmp")
rast_01 = raster(bmp_01)
plot(rast_01)

20231031_110019.bmp.zip

From what I've found googling, if I can convert the raster to an owin object or ppp (hypothetical name ppp_01), I can then calculate the area of the discrete ovoid regions in the object using the following code:

islands_dd <- dilation(ppp_01, 0.5, polygonal=FALSE)
islands_image_P <- connected(islands_dd)
islands_B <- tess(image = islands_image_P)
answer <- tile.areas(islands_B)

So I have at least two possibilities:

  1. Convert the raster into an object that can be manipulated with the above code. From what I've read, maptools is required to convert objects like rasters into a ppp or im or owin object. The maptools package is no longer available from CRAN and I am unfortunately unable to install maptools even with:
require('devtools')
install_github("ropensci/maptools")
  1. Find another way to calculate the area of the discrete 'islands' in my raster.

If you can help me figure out how to get my desired result, I would be SO grateful!

Many thanks,
foreignsand

Repo/Task View Name?

Was wondering if this was the best name for a task view, given that it is also the name of package?

Perhaps just simply "Mapping" or "Mapping and Cartography" or "Spatial Data Visualization"?

Thoughts?

USAboundaries

Another map data source? USAboundaries: Historical boundaries of the United States, 1629-2000. If this is in scope Iet me know and I'll make a pull request.

Review

@karthik and @sckott

So after quite a while, I think I have a draft close.

There is at least enough in here for a review of the language, layout, included packages, etc.

Also, I'm not an svn guy so I'll need some help (or instructions) on pushing up to CRAN when we think we are done.

Visualisation

  • sp (lattice)
  • ggmap (ggplot2)
  • micromap - linked micromap plots (with ggplot2)
  • Rgooglemaps
  • plotGoogleMaps

Which visualisation supports different projections?

For a cartographer (or anyone else who makes a map) it is important in which projection the map is shown. Many of the packages listed under "visualisation" only provide maps in the web mercator projection. Another property is whether the maps allow zooming / panning (in a browser), or further interaction with features, or are more static (on other R graphics devices).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.