Giter VIP home page Giter VIP logo

osmscale-1's Introduction

intro

OSMscale is an R package to easily handle and project lat-long coordinates, download background maps and add a correct scale bar to 'OpenStreetMap' plots in any map projection. There are some other spatially related miscellaneous functions as well.

installation

OSMscale is available on CRAN: CRAN_Status_Badge downloads Rdoc

It relies on OpenStreetMap to do the actual work, thus rgdal and rjava must be available.

  • On Windows: Check if Java is available. There should be no errors when running install.packages("rJava") ; library(rJava) in R. If necessary, install Java in the same bit-version as R (eg 64bit). The Java binary file must be on the search path, which will normally happen automatically.

  • On Linux: open a terminal (CTRL+ALT+T) and paste (CTRL+SHIFT+V) the following line by line to install gdal and rJava:

sudo apt update
sudo apt install libgdal-dev libproj-dev
sudo apt-get install r-cran-rjava
R
install.packages("rgdal")
library("rgdal"); library("rJava") # should not return errors
q("no") # to quit R
  • Now actually install OSMscale from within R:
install.packages("OSMscale") 
library(OSMscale)
?OSMscale

# To update to the most recent development version:
berryFunctions::instGit("brry/berryFunctions")
berryFunctions::instGit("brry/OSMscale")

basic usage

Assuming a data.frame with lat-long coordinates:

d <- read.table(sep=",", header=TRUE, text=
"lat, long # could e.g. be copied from googleMaps, rightclick on What's here?
55.685143, 12.580008
52.514464, 13.350137
50.106452, 14.419989
48.847003, 2.337213
51.505364, -0.164752")
png("ExampleMap.png", width=4, height=3, units="in", res=150)

map <- pointsMap(lat, long, data=d, type="maptoolkit-topo", proj=putm(d$long), scale=FALSE)
scaleBar(map, abslen=500, y=0.8, cex=0.8)
lines(projectPoints(d$lat, d$long), col="blue", lwd=3)
points(projectPoints(52.386609, 4.877008, to=putm(zone=32)), cex=3, lwd=2, col="purple")

dev.off()

ExampleMap

trouble

If direct installation doesn't work, your R version might be too old. In that case, an update is really recommendable: r-project.org. If you can't update R, try installing from source (github) via instGit as mentioned above. If that's not possible either, you might be able to source some functions from the package zip folder

Vectorize(source)(dir("path/you/unzipped/to/OSMscale-master/R", full=T))

This creates all R functions as objects in your globalenv workspace (and overwrites existing objects of the same name!).

osmscale-1's People

Contributors

brry avatar

Watchers

 avatar  avatar

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.