Geospatial data: weird longitude/latitude to the shapefile - r

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.

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.

How can I edit the values of coordinates within a geojson file?

I am trying to map a geojson file (A map of Alaska precincts, downloaded from the division of elections and then converted online to geojson) onto a choropleth map using folium, the problem is the coordinates are in 7-digit numbers like this:
[ -16624764.227, 8465801.1497 ]
I read on a similar post that this was most likely a US coordinate system like UTM or State Plane, and recommended using an API to reproject it. Is it also possible to access the coordinates directly such as with geopandas and divide them by 100000?
The data is most likely in a specific cartographic projection. You don't just want to divide by 100k - the data will likely have nonlinear transformations which have a different effect on the position depending on the location. See the GeoPandas docs on working with projections.
If the CRS of the data is correctly encoded, you can re-project the dataframe into lat/lons (e.g. WGS84, which has the EPSG Code 4326) using geopandas.GeoDataFrame.to_crs, e.g.:
df_latlon = df.to_crs("epsg:4326")

Strange coordinate units

I received a .gdb file that I need to do analysis on. This is an ESRI file, but I don't have access to any ESRI products. I opened it in R using the "rgdal" package, but the coordinates it displays seem very off.
For example, (-9288065, 4604652) should map to Kentucky. My initial thought was that there are missing decimals, so it should be -92.88 and -46.04, but this maps to somewhere north of Kentucky, which is wrong.
Do these coordinate units look familiar? How might I convert them to latitude and longitude?
Solved with help from #camille.
For future users:
library(rgdal)
library(raster)
myFeatureClass<-readOGR('your_data_here')
#checks the projection type
sp::proj4string(myFeatureClass)
#convert projection to longlat
final_data <- as.data.frame(spTransform(myFeatureClass, CRS("+proj=longlat +datum=WGS84")))

proj4string doesn't seem to completely define ESRI projection information

I have a shapefile that I imported into R using readOGR from the rgdal package. I do a little bit of work with it, like adding attribute information, etc, then export it as an ESRI shapefile again, with a new name. However, when I bring both the original and new shapefile into ArcGIS, it tells me that the CRS does not match.
So, noting that all the projection parameters remain the same, but the projection and coordinate system names are different, and the datum
name is dropped, my questionas are:
Is the second CRS the same as the first?
If so, why did the names change, and why does ArcGIS no longer recognize it as the same?
If not, how did it get changed?
Can the proj4string be modified to be more specific, and if so, why did readOGR not already do this to preserve all the information?
I can use the new shapefiles just fine, but it would be nice to know that
the CRS is identical to the original. And, I could of course define it again in ArcGIS, but part of the motivation to work in R
is to obviate the need to point and click for many files.
I appreciate any insights or enlightenment.
Here is the original projection information from ArcGIS:
Projected Coordinate System: NAD_1983_HARN_Transverse_Mercator
Projection: Transverse_Mercator
False_Easting: 520000.00000000
False_Northing: -4480000.00000000
Central_Meridian: -90.00000000
Scale_Factor: 0.99960000
Latitude_Of_Origin: 0.00000000
Linear Unit: Meter
Geographic Coordinate System: GCS_North_American_1983_HARN
Datum: D_North_American_1983_HARN
Prime Meridian: Greenwich
Angular Unit: Degree
Here is the proj4string from R, which also agrees with the proj4string given for this projection at www.spatialreference.org for epsg:3071 and also for SR-ORG:7396.
+proj=tmerc +lat_0=0 +lon_0=-90 +k=0.9996 +x_0=520000 +y_0=-4480000 +ellps=GRS80 +units=m +no_defs
When I use writeOGR to export the SpatialPolygonsDataFrame with the above proj4string, then bring it back into ArcGIS, the
projection information is given as the following, and is no longer recognized as the original.
Projected Coordinate System: Transverse_Mercator
Projection: Transverse_Mercator
false_easting: 520000.00000000
false_northing: -4480000.00000000
central_meridian: -90.00000000
scale_factor: 0.99960000
latitude_of_origin: 0.00000000
Linear Unit: Meter
Geographic Coordinate System: GCS_GRS 1980(IUGG, 1980)
Datum: D_unknown
Prime Meridian: Greenwich
Angular Unit: Degree
Perhaps not a definitive answer, but I posted this question on the R-sig-Geo list serve, and got a few possible work-around solutions. For now, I simply used an R-script to overwrite the .prj file with a copy of the original, and that seems to work fine. Also suggested was the use of a package called arcgisbinding to bridge ArcGIS and R (and maybe a similar solution would be available for QGIS?). I have not verified the arcgisbinding solution, but more information can be found at the the blog post here and in the package documentation here.

Can ggmap base map be converted to UTM?

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 !

Resources