Can ggmap base map be converted to UTM? - r

I am wondering whether the reference coordinates of the base map acquired using get_googlemap() of ggmap can be converted to UTM coordinate system ?
I would like to display a heatmap on a base map of a city acquired by get_googlemap(). The data of my heatmap is referenced in UTMs (i.e. metres) as I find these coordinates more meaningful at the city scale than decimal degrees. I have researched SO but it seems the solutions are to go the other way i.e. to convert the heat map UTM data into lat long system, but this is not my preference.
Has anyone a solution for this ? Any guidance and help is greatly appreciated.
Many thanks !

Related

UK BNG (Easting/Northing) to lat/long in R

I am a new user of R and I have a project where some coordinates are provided in British National Grid coordinates. These are not recognised by our preferred mapping program, so I would prefer to convert to lat/long. I have found some resources on how to do this using the code below:
require("rgdal") || install.packages("rgdal")
require("sp") || install.packages("sp")
library(rgdal)
# prepare UTM coordinates matrix
utmcoor<-SpatialPoints(cbind(knime.in$"Easting",knime.in$"Northing"), proj4string=CRS("+proj=utm +zone=30"))
#utmdata$X and utmdata$Y are corresponding to UTM Easting and Northing, respectively.
#zone= UTM zone
# converting
longlatcoor<-spTransform(utmcoor,CRS("+proj=longlat"))
However, the results are not what I was expecting. I tried an Easting/Northing for somewhere in Greenwich as an example and the point eventually mapped was somewhere off the Ivory Coast! I don't think UTM here is the correct system to specify, but I do not know how to specify BNG. I don't think I'm too far off solving the problem, but I could do with a bit of assistance. Thank you!
Example:
Tried the above code with East./North. 537869 , 178976. Was expecting 51.492927 , -0.015449524, but got the result -2.6595478348955846, 1.6192189249637292 instead.

R group locations by street

I have multiple (~200,000) longitude/latitude coordinates and I would like to group them by street name. Using reverse geocoding is a solution, but it takes a long time (tried tidygeocoder).
Any other suggestions ?
Thank you!
A possible solution .. (as a note to myself and anyone who may get interested):
oe_get from osmextract gets the street names and geometry of the place.
Then we find the street where each of our points belongs with st_nearest_feature of the sf package.

Introducing random noise into point positions

I am using R and Leaflet for R to plot 1000s of points. The raw data is imported to a data frame from SQL Server as British National Grid (BNG) coordinates (Transverse Mercator) which are then converted to lat/long using rgdal before outputting to a stand-alone html via from a Leaflet widget.
The BNG coordinates have been produced by geocoding postcodes and so, when >1 person has the same postcode the coordinate is the same.
I would like to add some random noise to the last 2-digits of each easting/northing coordinate so that all points are likely to be visible in Leaflet. What would be the simplest way to achieve this?
thanks
mike
Two solutions to overplotting are
"jittering" the points by adding some random noise to their coordinates and
adding transparency to the point color so you can see point density.
x=jitter(x), y=jitter(y) will accomplish #1.
col=scales::alpha("blue", 0.5) will accomplish #2.

Geospatial data: weird longitude/latitude to the shapefile

I am just getting started with geospatial data and have a question related to longitude/latitude. I downloaded the shapefile for the French departments (http://professionnels.ign.fr/geofla) and used R to read in the data:
library(rgdal)
library(maptools)
map <- readOGR(dsn="...",layer="DEPARTEMENT")
map_f <- fortify(map)
head(map_f)
If I look at the longitude-latitude, it are numbers like long = 885661.8, lat = 6679942. In contrast, the long-lat combination for Paris is 2.352222, 48.85661 (geocode("Paris")). So I don't really get why the numbers are so different in magnitude? Can somebody help me or give some good references?
Thanks in advance!
The coordinates look projected (perhaps UTM) and not lat,long. I think that the fields are just mislabeled. I do not read French but in quick scan of the site you linked this caught my eye:
En métropole : (RGF 93) projection Lambert93
En outre-mer : (système légal)- Projections UTM
Neither of which are geographic coordinate systems. Please track down the metadata and check the coordinate system. You can also check proj4string(map) to see it there is a coordinate system defined.

Correctly compare areas from multiple parts of the globe using longitude and latitude

Here's my problem. I want to compare the area within multiple polygons in different parts of the world. I have the longitude and latitudes for each point of each polygon. My problem is that I don't know what projection to use to get x-y coordinates from the long-lat coordinates. I know OpenStreetMap has the projectMercator() function, but areas are known to inflate quite badly with latitude. (http://en.wikipedia.org/wiki/List_of_map_projections)
--> Do you guys know of an R function like projectMercator, that doesn't have such a distortion? I've been going over different types of projections in Wikipedia, but it's very unclear to me which is best for area comparisons, and then if those projections exist in R as functions (if they don't I'm fine hand coding them, though!)
Thanks!!!
Hillary

Resources