[GRASS-user] Import R point dataframe as points in GRASS

David Montoya jdmonto0 at gmail.com
Fri Jun 8 07:01:51 PDT 2012


Hi,

You can do that using the library spgrass6.
First you have to start Grass into the Mapset in which you wanna put your
vector map, then start R inside Grass and call the library spgrass6,
convert your data frame to a spatial points data frame:

> temp_spatial <- SpatialPointsDataFrame(coords,data)

Finally, move your spatial data frame to your Mapset:

>
writeVECT6(temp_spatial,"map_name_in_grass",v.in.ogr_flags=c("o","overwrite"))

On Fri, Jun 8, 2012 at 7:44 AM, Johannes Radinger <JRadinger at gmx.at> wrote:

> Hi,
>
> I have a R data.frame containing around 60 columns, two of them are X and
> Y respectively. What is the recommended way to get these "points" imported
> into GRASS?
>
> Maybe the simplest way is to save the data.frame as csv and then use
> v.in.ascii in GRASS. I tried to do that and specified the columns for x and
> y and skipped the first line (header in the csv). The import works fine and
> all points are correctly imported but I miss the attribute names in the
> attribute table (header in the csv). Maybe I have just overseen this
> feature to use the header from the csv as attribute names... or is this
> just not possible?
>
> Or is there any other resp. better way to get points from R into GRASS?
> E.g. I could store them as spatial.points.data.frame in R but is there a
> native GRASS-format I could use for exporting/saving in R?
>
> any suggestions are welcome!
>
> /Johannes
> --
> NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone!
> Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>



-- 
David Montoya González
Ing. Forestal, Universidad Nacional de Colombia
Laboratorio de Sistemas Complejos, UNAL Medellin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20120608/e6ee0f43/attachment.html>


More information about the grass-user mailing list