-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Meridian-wrap artefacts in shapefile reprojected with sf::st_transform() #1495
Comments
Right after reading the geojson, I see
so there seems to be a problem with your input data. |
Good spot @edzer. Do you know the best practice way to rectify this? I find that the (hacky)
does in practice move the polygons, but |
Try crop the input to -180/180 after also zero-buffering (that decomposes the shapes to segments and forces a degeneracy fix for some problems, and appears to work with your data). Hacky? Sure, but balance that with what you need to do ;) library(sf)
#> Linking to GEOS 3.8.0, GDAL 3.0.4, PROJ 6.3.1
library(ggplot2)
m = read_sf('https://gist.githubusercontent.com/geotheory/b75a60e1659daa484e0f513a6350be79/raw/3838e475af1cdfa73bd94f68fd0807ed3e9c956f/robinson-artefacts.geojson')
m = st_buffer(m, 0) ## fixes some issues
#> Warning in st_buffer.sfc(st_geometry(x), dist, nQuadSegs, endCapStyle =
#> endCapStyle, : st_buffer does not correctly buffer longitude/latitude data
#> dist is assumed to be in decimal degrees (arc_degrees).
m = st_transform(st_crop(m, st_bbox(c(xmin = -180, xmax = 180, ymin = -90, ymax = 90))), crs = '+proj=robin +ellps=WGS84 +datum=WGS84 +no_defs')
#> although coordinates are longitude/latitude, st_intersection assumes that they are planar
#> Warning: attribute variables are assumed to be spatially constant throughout all
#> geometries
ggplot(m, aes(fill = value)) +
geom_sf(col = 'red', size=.5) +
theme_light() + theme(panel.border = element_blank()) Created on 2020-10-21 by the reprex package (v0.3.0) |
I'm getting 180° meridian-related artefacts when projecting a shapefile to Robinson - see horizontal red lines in the map below. Any suggestions why this is occuring or how to resolve?
The text was updated successfully, but these errors were encountered: