Skip to content
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

SOauto_crop is being weird #105

Open
Maschette opened this issue Sep 9, 2022 · 2 comments
Open

SOauto_crop is being weird #105

Maschette opened this issue Sep 9, 2022 · 2 comments

Comments

@Maschette
Copy link

SOauto_crop is kind of working but also not, what should be straight lines become really jagged. It also doesn't appear to crop to the right boundary.

library(SOmap)
#> Loading required package: raster
#> Loading required package: sp
library(ggplot2)


llproj <-"+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"

bigmap<-SOgg(SOmap_auto(x=c(45,145), y=c(-50, -70), input_points = F, input_lines = F, target = llproj))
bigmap

stat_areas <- SOauto_crop(SOproj(SOmap_data$CCAMLR_statistical_areas, target = llproj), x = bigmap, sp = F)
#> Warning in wkt(obj): CRS object has no comment

#> Warning in wkt(obj): CRS object has no comment
#> Warning in spTransform(xSP, CRSobj, ...): NULL target CRS comment, falling back
#> to PROJ string

ggplot(data=stat_areas, fill=NA)+geom_sf()+theme_bw()

Created on 2022-09-09 with reprex v2.0.2

@mdsumner
Copy link
Member

mdsumner commented Sep 9, 2022

what if you do

sf::sf_use_s2(FALSE)

then run again? We should bake that into the package

@Maschette
Copy link
Author

Maschette commented Sep 9, 2022

Yep that fixes it.
although in this particular instance the crop king of fucks up by drawing a line across 60 degrees, which I think is the peninsulas fault

library(SOmap)
#> Loading required package: raster
#> Loading required package: sp
library(ggplot2)
library(sf)
#> Linking to GEOS 3.9.1, GDAL 3.4.3, PROJ 7.2.1; sf_use_s2() is TRUE
sf::sf_use_s2(FALSE)
#> Spherical geometry (s2) switched off
llproj <-"+proj=longlat +datum=WGS84 +no_defs +ellps=WGS84 +towgs84=0,0,0"

bigmap<-SOgg(SOmap_auto(x=c(45,145), y=c(-50, -70), input_points = F, input_lines = F, target = llproj))
#> dist is assumed to be in decimal degrees (arc_degrees).
#> although coordinates are longitude/latitude, st_intersection assumes that they are planar
#> dist is assumed to be in decimal degrees (arc_degrees).
#> although coordinates are longitude/latitude, st_intersection assumes that they are planar
bigmap

stat_areas <- SOauto_crop(SOproj(SOmap_data$CCAMLR_statistical_areas, target = llproj), x = bigmap, sp = F)
#> Warning in wkt(obj): CRS object has no comment

#> Warning in wkt(obj): CRS object has no comment
#> Warning in spTransform(xSP, CRSobj, ...): NULL target CRS comment, falling back
#> to PROJ string
#> dist is assumed to be in decimal degrees (arc_degrees).
#> although coordinates are longitude/latitude, st_intersection assumes that they are planar

ggplot(data=stat_areas)+geom_sf(fill=NA)+theme_bw()

Created on 2022-09-09 with reprex v2.0.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants