prioritizr / wdpar

Interface to the World Database on Protected Areas
https://prioritizr.github.io/wdpar
GNU General Public License v3.0
39 stars 5 forks source link

wdpa_clean error #16

Closed ricschuster closed 4 years ago

ricschuster commented 4 years ago

Thanks for this awesome package Jeff!

Downloading the global dataset works fine.

wdpa_raw <- wdpa_fetch("global", wait = TRUE, 
                       download_dir = here("WDPA/"))

When I run the following with a crs setting of proj4string(base_raster) = _"+proj=eck4 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +units=m +nodefs"

wdpa <- wdpa_clean(wdpa_raw, crs = proj4string(base_raster))

I'm getting this error message:

>----------------------] 19778/228652 (  9% eta:) eta:  2d
[=>----------------------] 19779/228652 (  9% eta:) eta:  2dError in CPL_geos_op2(op, st_geometry(x), st_geometry(y)) : 
  Evaluation error: TopologyException: Input geom 1 is invalid: Too few points in geometry component at or near point -9268899.2860000003 6380069 at -9268899.2860000003 6380069.

I will rerun without setting crs now, but wanted to bring this to your attention. Thanks, Richard

jeffreyhanson commented 4 years ago

Hi,

I haven't seen that error message before. In general, I wouldn't really recommend trying to clean the global dataset with this package as none of the functions are parallel and can take a long time to run with such a large dataset. I would generally recommend trying out https://github.com/jeffreyhanson/global-protected-areas instead which uses ESRI ArcMap.

That being said, if you plan on rasterizing the protected area boundaries then you probably don't need to get rid of overlapping geometries, so you could skip this step using:

wdpa <- wdpa_clean(wdpa_raw, crs = proj4string(base_raster), erase_overlaps = FALSE)
ricschuster commented 4 years ago

Thanks very much Jeff! Will check out the global-protected-areas repo for sure.