3

Not the best practice, but somethimes I need to change between ArcGIS 10.6 and R (version 3.6.1) to process my shapefiles. For example, I want to read my shapefile in R -> process it -> export it back to ArcGIS.

But, the projection of my data changes in between: I read the shapefile in one coordinate system, export it in same CRS, but ArcGIS reads it as different projection.

Let's see on watershed dataset:

I work on Finland watersheds. In ArcGIS, it has projection EUREF_FIN_TM35FIN, WKID 3067

enter image description here

After loading this file to R, the projection is a string:

library(rgdal) 
library(sp)

setwd("U:/rawData/Finland/watershed/valuma")

watershed = readOGR(dsn = "U:/rawData/Finland/watershed/valuma",
                    layer = "Jako3")

proj4string(watershed)
# [1] "+proj=utm +zone=35 +ellps=GRS80 +units=m +no_defs"

This is how the this projection string should look like reffering to spatialreference.org:

+proj=utm +zone=35 +ellps=GRS80 +units=m +no_defs 

But, after exporting this file to new .shp:

# Add the stand geometry
writeOGR(obj    = watershed, 
         dsn    = getwd(), 
         layer  = "watershed_no", 
         driver = "ESRI Shapefile",  
         overwrite_layer=TRUE)

ArcGIS now reads this projection as Custom projection (even not listed within ArcGIS library!!!) as UTM_Zone_35_Northern_Hemisphere!!

enter image description here

I have tried to transform my data to correct CRS before exported in R:

watershed.t <- spTransform(watershed, CRS("+init=epsg:3067"))

But, ArcGIS still reads this as a Custom CRS. How to define my CRS in R, to be correctly read in ArcGIS? Or how can I avoid its change between softwares?

EDIT:

I have tried both suggestions:

  1. Specify the watershed@proj4string@projargs by adding +init=epsg:3067

    watershed@proj4string@projargs <- paste0('+init=epsg:3067 ', watershed@proj4string@projargs)
    
  2. transform my data using spTranform and specify epsg:

    watershed.t <- spTransform(watershed, CRSargs(CRS("+init=epsg:3067")))
    

but they both produce the same output: Custom projection UTM_Zone_35_Northern_Hemisphere Authority: Custom in ArcGIS 10.6.

Do you have any other suggestions?

1
  • I would fret over this. It likely does not make a bit of difference in the resulting processing but, just test it to make sure. This is probably due to ArcGIS not having an exact UTM definition for the GRS80 spheroid. If it really concerns you just define a custom projection in ArcGIS, that matches the expected proj4 string, and assign it when you open the shapefile in the software. It is quite easy managing projections in ArcGIS. Jan 8 '20 at 14:17
1

I've had similar issues with R (raster), QGIS, and EPSGs 4151 and 4283, which have the same proj string. The EPSG code with the smallest number was getting assigned first on write.

I've been fixing it with something like

x@proj4string@projargs <- paste0('+init=epsg:XXXX ', x@proj4string@projargs)

before write, which is ugly but does the trick. Bear in mind the issues with case sensitivity in the linked question.

This should all resolve itself as newer versions of GDAL and PROJ make it into the R spatial ecosystem.

In the meantime, have you tried using the arcgisbinding package to handle I/O instead of writing to disk? Might help. https://r-arcgis.github.io/

1
  • thank you @obrl_soil for a nice suggestion and for arcgisbinding package suggestion, I will try this on! But, I still can't make it work using your answer. Do you have any other suggestions? or have I specified it wrongly? Thank you again
    – maycca
    Jan 8 '20 at 12:15
0

When transforming the data in R in your last step, try using the `CRSargs()’ instead of only CRS.

watershed.t <- spTransform(watershed, CRSargs(CRS("+init=epsg:3067")))
1
  • Thank you @Jelle, I have tried this, looks promising but I still get the not specified output. Maybe some other suggestions?
    – maycca
    Jan 8 '20 at 12:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.