Odd behavior with rasterToPolygons function in Raster package
I've got a raster with values 1 and NA. I'm attempting to convert to a polygon using the rasterToPolygons function with dissolve=TRUE. The raster is in an equal area projection (+proj=aea +lat_1=-5 +lat_2=-42 +lat_0=-32 +lon_0=-60 +x_0=0 +y_0=0 +ellps=aust_SA +units=m +no_defs )
When I use this command on the projected raster:
I get a SpatialPolygonsDataFrame with a single polygon but this plots several lines in the polygon (dissolve function partially working but not plotting as a simple perimeter of the polygon).
If I project the raster to a geographic coordinate system ("+proj=longlat +ellps=WGS84 +datum=WGS84 +no_defs"), I get the expected plot.
Both plots are attached.
I would appreciate any insight. This is part of a larger script and the projected raster/polygon is desirable.