3

I have a shapefile with no spatial reference nor projection, and a GEOTIFF that has the spatial reference and projection data. The shapefile was created from a segmentation analysis of the GEOTIFF, therefore the extent of the shapefile matches that of the GEOTIFF, and should be overlayed on the GEOTIFF. The two files can be found here.

I have tried the raster, sp and RGDAL packages, among others, to try to project/reproject the shapefile. Due to the size of the shapefile, it takes over 2 days to rasterize from the raster package. I have tried to convert a smaller shapefile (samp.shp) to a raster, then copy the projection of the GEOTIFF (geotiff) to the new sampled raster.

samp.shp.raster<-raster(samp.shp,res=r)
shp.rasPRO = projectRaster(samp.shp.raster, geotiff)

This seems to work on the sample, but I cannot get to reproduce it for my data. I think if I can convert the shapefile to a grid, then I can copy the X,Y coordinates of the geotiff to that grid, but I am not sure if this would work. I have >200 individual GEOTIFFs and corresponding shapefiles and I need to batch process. I am searching for the most efficient method of assigning the spatial reference and projection data to the shapefiles.

Any suggestions would be welcomed.

wittich
  • 2,356
  • 1
  • 16
  • 30
user2507608
  • 245
  • 1
  • 2
  • 9
  • I'm not quite sure from your question what exactly is the issue, but regarding the speed - maybe the package velox could help? – Janina Jul 13 '17 at 12:14
  • Thanks, I will try out the package. The issue is that I need the shapefile (with no spatial reference and undefined projection) to be assigned with the spatial reference and projection of the TIFF file, so when I view them, on is "on top" of the other. – user2507608 Jul 13 '17 at 14:50
  • @user2507608 I analyzed your data yesterday. It seems that the shapefile is referenced nearly to xmin,ymin = 0,0. So If the layers have the same extent, one can add an xOffset and an yOffset to all the coordinated from the shapefile and the layers should overlay (like 'moving' the layer from one position to another). The offsets should be calculated as: xOffset = xminGeotiff - xminShp and yOffset = yminGeotiff - yminShp. But I found that there are different offsets if xmin,ymin is used as the reference or xmax,ymax is used as the reference. So I couldn't make a transformation. – Guz Jul 13 '17 at 15:25
  • @ Guzmán Thanks for that insight. From that I tried to locate the transformation used on the data, and it seems to be : x' = 50000 + x*0.25 and y' = 1529000 + y*-0.25. I am thinking that it should give the same respective offset values. But dont know if this helps – user2507608 Jul 14 '17 at 05:41

0 Answers0