[R-sig-Geo] st_area / st_transform / crs
edzer.pebesma at uni-muenster.de
Sat Sep 16 14:19:38 CEST 2017
On 16/09/17 13:52, Jean-Luc Dupouey wrote:
> Dear all,
> I am a new user of sf. I have the following error:
> "lay" is an sf object, composed of POLYGONS and MULTIPOLYGONS in a
> projected coordinates system.
>> st_area(lay) # works well and returns the area of polygons
>> # convert to WGS
>> laywgs = st_transform(lay, 4326)
> Error in as_Spatial(from) :
> conversion from feature type sfc_GEOMETRY to sp is not supported
> Why st_area works on the projected layer and not on the
> latitude/longitude layer? I read carefully the manual and did not find
> any clue. It is just told that for unprojected geometries, st_area uses
> areaPolygon. Well... it means that some conversion probably takes place,
> but there is no information about this conversion.
If you then would read the documentation of geosphere::areaPolygon, you
can read that it needs sp objects as its input; sf converts to Spatial
(sp), then calls areaPolygon on that object.
laywgs = st_transform(st_cast(lay, "MULTIPOLYGON"), 4326)
to make this conversion less painful.
> Thank you advance for your help,
Thanks for bringing this up - I understand it is confusing, and we might
be able to make this simpler from the sf side.
> Jean-Luc Dupouey
Institute for Geoinformatics (ifgi), University of Münster
Heisenbergstraße 2, 48149 Münster, Germany; +49 251 83 33081
Journal of Statistical Software: http://www.jstatsoft.org/
Computers & Geosciences: http://elsevier.com/locate/cageo/
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 473 bytes
Desc: OpenPGP digital signature
More information about the R-sig-Geo