edeaster / Routes3D

3D maps with plotted gps route
23 stars 8 forks source link

coordinate issues? #2

Open RvV1979 opened 4 years ago

RvV1979 commented 4 years ago

Hi, I have tried the code with the latest version of rayshader (0.13.6) and the GPS track is not projected appropriately onto the rayshader map., see image below: 3D_map_no_overlay *note that I did not apply the overlay; all else is according to your code.

Did perhaps the rayshader lat-long to x-y coordinate transformation change since you developed this code? It seems like the origin has moved to the centre of the map.

j-reimer commented 4 years ago

Hi, I have tried the code with the latest version of rayshader (0.13.6) and the GPS track is not projected appropriately onto the rayshader map., see image below: 3D_map_no_overlay *note that I did not apply the overlay; all else is according to your code.

Did perhaps the rayshader lat-long to x-y coordinate transformation change since you developed this code? It seems like the origin has moved to the centre of the map.

Hello,

I had this same issue and noticed the centering issue seemed to be caused by adjusting the gpx track by the xmin and ymin values only, causing the outer edges of the track to centre on the image. I got around this by adjusting the x and y vectors to centre on the average of the min and max values, similar to how the call for the image overlay was structured:

`xmin <- elev_img@extent@xmin ymin <- elev_img@extent@ymin xmax <- elev_img@extent@xmax ymax <- elev_img@extent@ymax

x_vec <- rep((xmax+xmin)/2,length(gpx$lon)) y_vec <- rep((ymax+ymin)/2,length(gpx$lat)) x <- (gpx$lon-x_vec)/res(elev_img)[1] y <- (gpx$lat-y_vec)/res(elev_img)[2]`

This solved the centering issue for me. Alternatively you could take the average of the min and max values by averaging them when calling the extent values rather than creating two more values and nesting the formula in the vector formula.