TransWikia.com

How to make x and y tick labels to be printed as geographic coordinates in levelplot in R?

Geographic Information Systems Asked by raghav on September 14, 2020

I am trying to make a point raster plot using "levelplot". I want my x and y tick labels to be printed as Geographic coordinates (e.g. 101°W, 100°W, …34°N, 35°N, etc.). Following is the test data and code I tried so far:

library(rasterVis)
library(raster)
library(colorRamps)
x <- c(-98.02,-96.66,-98.29,-100.53,-95.86,-102.49,-99.64,-99.27,-97.00,-96.33,-96.80,-98.36,-99.72,-96.32,-98.03,-99.80,-98.49,-96.42,-101.60,-95.64,-96.00,-98.48,-99.83,-97.76,-98.11,-95.99,-97.21,-99.01,-94.84,-97.60,-97.46,-96.76,-97.04,-98.96,-99.04,-96.03,-97.09,-96.06,-99.13,-98.52,-97.98,-94.68,-99.41)

y <- c(34.80,34.79,34.91,36.80,35.96,36.69,36.83,35.59,34.87,34.60,35.65,36.74,35.54,33.92,35.54,35.20,36.26,36.84,36.60,35.78,35.84,35.48,34.65,34.52,36.38,34.30,36.06,36.98,36.88,36.15,35.23,36.36,35.95,35.04,36.19,36.41,36.12,34.87,34.43,35.84,34.16,34.98,36.42)

z <- c(0.36,0.78,0.32,0.75,0.91,0.11,0.52,0.08,0.6,0.84,0.53,0.58,0.12,0.45,0.44,0.26,0.3,0.78,0.15,0.83,0.71,0.23,0.13,0.73,0.23,0.81,0.61,0.18,0.68,0.34,0.72,0.84,0.79,0.55,0.38,0.92,0.94,0.8,0.19,0.5,0.96,0.71,0.41)

col=colorRampPalette(matlab.like2(255))
levelplot(z ~ x + y, xlim=c(-103.5,-94), ylim=c(33.2,37.5), panel = panel.levelplot.points, cex = 2, contour = FALSE, margin = FALSE, col.regions = col,xlab = list("Longitude", cex = 2), ylab = list("Latitude", cex=2),scales = list(tck = c(1,0), cex=1.5)) 

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP