[R-sig-Geo] Shape to DB, DB to SpatialPolygon

Carson Farmer carson.farmer at gmail.com
Thu Apr 8 13:17:52 CEST 2010


Hi Germán,

Have a look at package rgdal and the readOGR function.

> library(rgdal)
> ?readOGR

Here is a link with a quick bit on using rgdal to access a postgis table:
http://wiki.intamap.org/index.php/PostGIS

Regards,

Carson

On Thu, Apr 8, 2010 at 11:21 AM, Germán Sánchez
<german.sanchez at ais-int.com> wrote:
> Dear all,
>
> I've working with spatial data since only a few months. I know how to
> handle this kind of data in R using the sp package. I know how to load
> shapes, plot them, merge their polygons, plotting labels, etc.
>
> I have installed a postgis database and I can connect to it from R via
> RODBC without problems. I can load a shape file (.shp and so) into the
> database (command shp2pgsql  to create the needed .sql). It creates a
> table with some usual fields (area, perimeter, district, etc) and the
> special one: the_geom.
>
> Now, I want to load this data to a SpatialPolygon (or
> SpatialPolygonDataFrame) object using the RODBC driver. I would like to
> get the same object as if I have used the "readShapePoly" function from sp
> package directly over the .shp file.
>
> Any idea? Is there a direct solution or I have to build the polygon myself?
>
> Thank you,
> Germán Sánchez
> german.sanchez at esade.edu
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
Carson J. Q. Farmer
ISSP Doctoral Fellow
National Centre for Geocomputation
National University of Ireland, Maynooth,
http://www.carsonfarmer.com/



More information about the R-sig-Geo mailing list