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

Polygonizing single cell/single col rasters leads to errors/warnings #25

Open
frousseu opened this issue Nov 27, 2020 · 1 comment
Open

Comments

@frousseu
Copy link

Hello!

I noticed that using polygonize on a single cell raster leads to an error. With a single column raster, it leads to a warning. Below is an example. This is with spex 0.7.1. Thanks!

library(raster)
library(sf)
library(spex)
 
r<-setValues(raster(ncol=1,nrow=1),1)
polygonize(r)

## Error in seq_len(ncol(IB)) : 
##  argument must be coercible to non-negative integer
## In addition: Warning messages:
## 1: In rbind(aa, aa[2:1, ]) :
## number of columns of result is not a multiple of vector length (arg 2)
## 2: In c(rbind(aa, aa[2:1, ])) + c(0, 0, nc1, nc1) :
##  longer object length is not a multiple of shorter object length
## 3: In seq_len(ncol(IB)) : first element used of 'length.out' argument
 
r<-setValues(raster(ncol=1,nrow=2),1)
polygonize(r)

## Simple feature collection with 2 features and 1 field
## geometry type:  POLYGON
## dimension:      XY
## bbox:           xmin: -180 ymin: -90 xmax: 180 ymax: 90
## CRS:            +proj=longlat +datum=WGS84 +no_defs
##  layer                       geometry
## 1     1 POLYGON ((-180 90, 180 90, ...
## 2     1 POLYGON ((-180 0, 180 0, 18...
## Warning messages:
## 1: In rbind(aa, aa[2:1, ]) :
##   number of columns of result is not a multiple of vector length (arg 2)
## 2: In c(rbind(aa, aa[2:1, ])) + c(0, 0, nc1, nc1) :
##   longer object length is not a multiple of shorter object length
 
r<-setValues(raster(ncol=2,nrow=1),1)
polygonize(r)

## Simple feature collection with 2 features and 1 field
## geometry type:  POLYGON
## dimension:      XY
## bbox:           xmin: -180 ymin: -90 xmax: 180 ymax: 90
## CRS:            +proj=longlat +datum=WGS84 +no_defs
##   layer                       geometry
## 1     1 POLYGON ((-180 90, 0 90, 0 ...
## 2     1 POLYGON ((0 90, 180 90, 180...

r<-setValues(raster(ncol=2,nrow=2),1)
polygonize(r)

## Simple feature collection with 4 features and 1 field
## geometry type:  POLYGON
## dimension:      XY
## bbox:           xmin: -180 ymin: -90 xmax: 180 ymax: 90
## CRS:            +proj=longlat +datum=WGS84 +no_defs
##   layer                       geometry
## 1     1 POLYGON ((-180 90, 0 90, 0 ...
## 2     1 POLYGON ((0 90, 180 90, 180...
## 3     1 POLYGON ((-180 0, 0 0, 0 -9...
## 4     1 POLYGON ((0 0, 180 0, 180 -...
@mdsumner
Copy link
Owner

Thanks, actually thought this had been fixed will check ,👍

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