[R] convert opengis wkt to geometry?

Roger Bivand Roger.Bivand at nhh.no
Tue Dec 16 14:07:58 CET 2008


Jeff Hamann <jeff.hamann <at> forestinformatics.com> writes:

> 
> After writing some code (stupidly without checking to see if there was 
> code to do this already) to generate PostGIS SQL insert statements for 
> simple geometry (wkt), I didn't check see if there is already something 
> available to convert WKT strings into some R package geometry (sp?). 
> Does anyone have any advice, hints, code (?) for converting the 
> following OpenGIS strings into something useful in R:

If you are thinking of PostGIS, then readOGR() in rgdal will read them if build
with the necessary driver(s). On Linux and/or OSX, the user would configure
OGR to choose the external headers and libraries. On Windows, the user might
choose to install rgdal from source against the FWTools DLLs, which are at:

http://fwtools.maptools.org/

The PostGIS driver is described here:

http://www.gdal.org/ogr/drv_pg.html

There are some notes on using the driver with rgdal here:

http://wiki.intamap.org/index.php/PostGIS

> 
> POINT, MULTIPOINT, LINESTRING, MULTILINESTRING, POLYGON, MULTIPOLYGON,
> GEOMETRYCOLLECTION

In principle, only POINT, LINESTRING, and POLYGON (maybe MULTIPOLYGON, but
handled like a shapefile, that is flattened) are supported in sp/rgdal.

Please consider following up on R-sig-geo; there are possibly more eyes with
relevant experience there.

If the OpenGIS strings could rather be treated as GML, OGR has a driver for that
too.

Roger Bivand

> 
> Jeff.
>



More information about the R-help mailing list