[R-sig-Geo] Querying Spatial Data Using rgdal

Roger Bivand Roger.Bivand at nhh.no
Tue May 11 13:21:20 CEST 2010


On Sat, 8 May 2010, Brooks Kehler wrote:

> Have a look at:
>
> http://www.joeconway.com/plr/
>
> http://www.bostongis.com/PrinterFriendly.aspx?content_name=postgresql_plr_tut01
>

That only gets you so far. Could Tim please try ogr2ogr with the -sql or 
-where or -spat arguments set to see whether these go in the correct 
direction, that is returning geometries meeting the given selection 
conditions? I have looked briefly at how hard it would be to add this 
functionality to readOGR(), but without a substantial re-write, it will 
not be easy. If there are other users who would value such an addition to 
readOGR, please indicate!

Roger

>
>
> On Fri, May 7, 2010 at 5:35 PM, Tim Romel <tim.romel at vistracks.com> wrote:
>
>> I have the need to bring spatial data into R from a postgres database.  I
>> am
>> trying to do this right now using rgdal with a command similar to the
>> following:
>>
>> results=readOGR("PG:dbname='dbname' host='hostname' port='portnum'
>> user='username' password='pass' <password='P at ssw0rd'>, layer="tablename")
>>
>> This works in bringing back all data from the entire table.  However, this
>> is a very large table and I was wondering if there was a way to run a query
>> against the table instead of bringing back all data using readOGR.  I have
>> found no examples anywhere and have even seen suggestions that it is not
>> possible.  Is this the case?  If there are other libraries that support R's
>> SP library that allow access to postgres that would be great to know too.
>>
>> Any help is much appreaciated.
>>
>> Thanks.
>>
>>        [[alternative HTML version deleted]]
>>
>> _______________________________________________
>> R-sig-Geo mailing list
>> R-sig-Geo at stat.math.ethz.ch
>> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>>
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at stat.math.ethz.ch
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no



More information about the R-sig-Geo mailing list