Re: [R-sig-Geo] adding maps to spplot
2013/5/16 Alemu Tadesse alemu.tade...@gmail.com I am plotting a krigged values of irrdiance with the following command. spplot(p1, zcol=insol.pred, col.regions=terrain.colors(30), cuts=30, sp.layout=list(pts1), contour=TRUE, labels=TRUE, pretty=TRUE, col='brown', main=title1) I want to overlay California (for that matter any future state for which I do similar work) on the plot How am I going to do that. Where am I going to get the map information and which command is used. I was trying gadm and there was no success for me. I think I am missing something very basic. just define something like that CAL.POL - list(sp.polygons, california, lwd=1.5) where california is a shape file you want to read into R with california - readShapePoly('path_to_your_shape_file') then, according to your spplot, add CAL.POL to your sp.layout list spplot(p1, zcol=insol.pred, col.regions=terrain.colors(30), cuts=30, sp.layout=list(pts1, CAL.POL), contour=TRUE, labels=TRUE, pretty=TRUE, col='brown', main=title1) Of course I've used upper case just for highlights purpose hope this helps /r [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] reading PostGIS table into sp data frame
2012/12/19 Edward Vanden Berghe evber...@gmail.com I wanted to create a global map with squares in lat-lon. I have PostGIS tables to define these squares but I havent been able to figure out an efficient way of reading those tables into R. The code I am using now is: crs - CRS(+proj=longlat +ellps=WGS84) s - paste(select id, st_astext(geom) as geom from geo.cs10d;, sep=) r - dbGetQuery(con, s) p - readWKT(r$geom[1],id=r$id[1],p4s=crs) for(i in 2:length(r$id)){ p - rbind(p, readWKT(r$geom[i], id=r$id[i], p4s=crs)) } where geo.cs10d is the table with squares, id the primary key of the table, and geom the binary geometry field. The code above works fine for the larger squares, such as 10 degrees, of which I only need 648 to cover the globe. For finer resolutions, the above takes just too long I assume because the rbind function rewrites the whole sp object each time it executes. Ive seen other R scripts that initiate an empty data frame of the correct length to go round similar problems with the rbind function; I havent been able to find an equivalent for spatial polygons. How can I initiate an empty data frame with the right structure, and the right length? A preferable solution would be if there would be a single function to load a complete PostGIS table, rather than having to load the polygons one by one in a loop. Is there such a function? Im using PostgreSQL 8.4, PostGIS 1.5, R 2.15.2, platform x86_64-w64-mingw32; IDE is StatET 3.0.1 plugin for Eclipse 3.7.2. Any help would be much appreciated. Edward Use postgis st_transfom to convert your table in epsg:4326, I would suggest to use a view for that. Then use readOGR (in package rgdal) to read the table/view (geom and attributes) in a sp object with : sp.object - readOGR(PG:dbname=your_db host=your_host user=username password=xxx, geo.cs10d ) regards -r -- *L'unica speranza di catarsi, ammesso che ne esista una, resta affidata all'istinto di ribellione, alla rivolta non isterilita in progetti, alla protesta violenta e viscerale. (V. Evangelisti) * [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] Raster memory problem
2012/12/12 Marie Auger-Methe marie.augerme...@gmail.com Dear list, I am using large raster bricks for my analyses and I am running out of memory. I get the following message: Error: cannot allocate vector of size 231.0 Mb and this whether I do all my brick manipulations by loading the brick in R's memory or not (i.e., whether I use the option filename=name of my file). The strangest characteristic of the problem I have is that I get an error message when I handle smaller brick and not when handle larger brick. I have clean up my computer, defragmented it, increase my virtual memory, etc, and I still get an error. Any help will be greatly appreciated, Marie Welcome to the band called Three of us (can't handle such big rasters) ;-) -raffaele [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] installing rgdal on Debian
2012/12/7 Eduardo Bieñkowski eduko...@gmail.com Hi all. For those who had the same problem: The solution was: In Ubuntu / Debian sudo apt-get install-dev libgdal1 sudo apt-get install-dev libproj Eduardo install-dev it's not an apt-get option... He's on Debian and according to the release he's using he needs libgdal-dev (testing/wheezy) or libgdal1-dev (stable/squeeze) Keep in mind that ubuntu it's debian based but it's not Debian... regards -r [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] installing rgdal on Debian
2012/12/6 Hodgess, Erin hodge...@uhd.edu Hello! I'm trying to install rgdal on Debian. I keep getting the checking for gdal.h...no error. I have updated libgdal1.dev. I also put the /usr/include and /usr/include/gdal in my PATH. Any ideas as to what is wrong, please? I have a feeling that it is something very simple. Thanks, Erin PS on R-2.15.2 According to http://packages.debian.org/search?suite=wheezyarch=anymode=exactfilenamesearchon=contentskeywords=gdal.h you need libgdal-dev and it should be enough... BTW you could try running ldconfig (but it's really not needed in debian unless you are installing from sources) -r -- *L'unica speranza di catarsi, ammesso che ne esista una, resta affidata all'istinto di ribellione, alla rivolta non isterilita in progetti, alla protesta violenta e viscerale. (V. Evangelisti) * [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] [plain text] Error: cannot allocate vector of size 274.7 Mb
2012/11/13 Mauricio Zambrano-Bigiarini mauricio.zambr...@jrc.ec.europa.eu: On 13/11/12 11:20, Raffaele Morelli wrote: Hi, sorry for double posting but I saw my messages were scrubbed from html garbage and don't know if nobody replies for that, but just in case... apologize if not. I am having trouble with this error when calculating a density on a point pattern dataset with 34480 points. My script exit when calculating z-density(mypattern, 3000, dimyx=3000) The machine the script it's running on it's a debian/amd64 OS with 16Gb RAM, I have set to unlimited the memory limits (the output of ulimit -a follows) Any ideas? Try: ?memory.limit ?gc and read 'Circle 2' of the R_inferno (www.burns-stat.com/pages/Tutor/R_inferno.pdf) IHTH, Mauricio Circle 2 is interesting but it's not my case, I do not costruct object that way and fetch data from a postgres/postgis database. Putting in the code lines such as cat('point 1 mem', memory.size(), memory.size(max=TRUE), 'nn') doesn't help because those commands are windows specific and I work on linux. Here follows a link to my script and RData, lines commented are not needed because objects are in the RData http://cen.isprambiente.it/~rmorelli/R/ I've just purged unusued objects from RData. Regards -r ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] [plain text] Error: cannot allocate vector of size 274.7 Mb
2012/11/13 Roman Luštrik roman.lust...@gmail.com: Would it be at all possible if you made your problem reproducible? Cheers, Roman Here follows a link to my script and RData, lines commented are not needed because objects are in the RData http://cen.isprambiente.it/~rmorelli/R/ Regards -r ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] [plain text] Error: cannot allocate vector of size 274.7 Mb
Hi, sorry for double posting but I saw my messages were scrubbed from html garbage and don't know if nobody replies for that, but just in case... apologize if not. I am having trouble with this error when calculating a density on a point pattern dataset with 34480 points. My script exit when calculating z-density(mypattern, 3000, dimyx=3000) The machine the script it's running on it's a debian/amd64 OS with 16Gb RAM, I have set to unlimited the memory limits (the output of ulimit -a follows) Any ideas? Regards -raffaele rmorelli@amb-asa1:~/R$ ulimit -a core file size (blocks, -c) 0 data seg size (kbytes, -d) unlimited scheduling priority (-e) 0 file size (blocks, -f) unlimited pending signals (-i) 128594 max locked memory (kbytes, -l) unlimited max memory size (kbytes, -m) unlimited open files (-n) 1024 pipe size(512 bytes, -p) 8 POSIX message queues (bytes, -q) 819200 real-time priority (-r) 0 stack size (kbytes, -s) 8192 cpu time (seconds, -t) unlimited max user processes (-u) 128594 virtual memory (kbytes, -v) unlimited file locks (-x) unlimited -- L'unica speranza di catarsi, ammesso che ne esista una, resta affidata all'istinto di ribellione, alla rivolta non isterilita in progetti, alla protesta violenta e viscerale. (V. Evangelisti) ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] [plain text] Error: cannot allocate vector of size 274.7 Mb
2012/11/13 Roman Luštrik roman.lust...@gmail.com: Would it be at all possible if you made your problem reproducible? Cheers, Roman I can upload my .RData (~45Mb) on a server and the script if you're willing to try. In the meanwhile I am doing some test with my owin taken from the maps dataset, I guess the one I am using is too much detailed. -r ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] rgdal spatstat: gtiff
Hi, I am using this code snippet to produce Gtiff images from density.ppp z-density(mypattern, 6000,dimyx=200) zgrid - as.SpatialGridDataFrame.im(z) writeGDAL(zgrid, 01.tif, type=Byte, options=INTERLEAVE=PIXEL) Gtiff image is generated but gdalinfo among others reports that: Image Structure Metadata: INTERLEAVE=BAND Band 1 Block=200x40 Type=Byte, ColorInterp=Gray The problem is I can not use the Gtiff image as a raster layer in mapserver and other webgis that relies on it. I need a three band interleave=pixel image in order to do that. Any hints is appreciated. Regards -r -- *L'unica speranza di catarsi, ammesso che ne esista una, resta affidata all'istinto di ribellione, alla rivolta non isterilita in progetti, alla protesta violenta e viscerale. (V. Evangelisti) * [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] kernel2d - raster/grid
Hi, how can I convert kernel2d estimation to a raster in order to use it as a mapserver layer? I saw maptools can save kernel2d to contour to shape file with ContourLines2SLDF. Any hints? Regards -r -- *L'unica speranza di catarsi, ammesso che ne esista una, resta affidata all'istinto di ribellione, alla rivolta non isterilita in progetti, alla protesta violenta e viscerale. (V. Evangelisti) * [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
Re: [R-sig-Geo] Splancs and polymap
2012/3/29 Roger Bivand roger.biv...@nhh.no On Thu, 29 Mar 2012, Raffaele Morelli wrote: Hi, I am working on a simple kernel2d analisys and would like to create a polymap from a SpatialPolygonsDataFrame, let's stay US states. how can I accomplish this task? can you point me to the right direction? Why? Please include sample code. I assume that you realise that the poly= argument in this function requires a single polygon ring, so you would first have to define your window and go from there. I have a SpatialPointsDataFrame all over Italy and I am calculating kernel2d for each district (24 administrative boundaries, eg. Lazio, Piemonte, Sicilia, Sardegna...) # I fetch Italy boundaries and the spdf from postgres with: districts - readOGR(PG:dbname= host=xxx user=xxx password=xxx, italy_utm32) points - readOGR(PG:dbname=xxx host=xxx user=xxx password=xxx, points_utm32) # I want to calculate kernel 2d for districts then the need to extract the poly for EACH of them using administrative boundaries for poly argument, so: regione - districts[districts$ditricts_id==cod,] # where cod is the district id # and then I solved the thread question using: poly - as.matrix(district@polygons[[1]]@Polygons[[1]]@coords) plot(regione, asp=1) image(kernel2d(as.points(points@coords), poly, h0=5000, nx=450, ny=450), add=TRUE, col=terrain.colors(10)) plot(regione, lwd=3, border=grey50, add=TRUE, axes=TRUE) I hope this is clear, apologize for my english :( Actually I am facing with another issue. Each dictrict can have isles, so I should guess the number of polygons object for each district eg. str(district@polygons[[1]]) Formal class 'Polygons' [package sp] with 5 slots ..@ Polygons :List of 37 .. and I should calculate kernel2d for each isle. So, how can I guess the list lenght (37 in the example above)? I tried using length(regione@polygons[[1]]) with no success... regards -r -- *L'unica speranza di catarsi, ammesso che ne esista una, resta affidata all'istinto di ribellione, alla rivolta non isterilita in progetti, alla protesta violenta e viscerale.* [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] Splancs and polymap
Hi, I am working on a simple kernel2d analisys and would like to create a polymap from a SpatialPolygonsDataFrame, let's stay US states. how can I accomplish this task? can you point me to the right direction? regards -r -- *L'unica speranza di catarsi, ammesso che ne esista una, resta affidata all'istinto di ribellione, alla rivolta non isterilita in progetti, alla protesta violenta e viscerale.* [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] bbox
Hi, once a Postgis layer X is retrieved, how can I juggle with subsets of X? eg. I am working with bubble plots on a EU dataset but I want to do test it only using a 30x30Km in the nearby of Rome and I have no attribute data but the value I use for the bubbles. Should I use subset? Can I set a kinda of custom bbox? regards -r [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo
[R-sig-Geo] readShapePoints issue
Hi, I am working with R and using pgsql2shp to export shape files from pg. The shapes are created by pgsql2shp but when I try to import them in a R enviromnent I get this error Error in res[i, ] - Map$Shapes[[i]]$verts : replacement has length zero So, I can load the shape files in Qgis but not in R. Moreover, if I load one of those files in Qgis and then export it again... this file is correctly loaded by R. I really can't guess what's wrong. Any idea? Regards Raffaele -- L'unica speranza di catarsi, ammesso che ne esista una, resta affidata all'istinto di ribellione, alla rivolta non isterilita in progetti, alla protesta violenta e viscerale. ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/mailman/listinfo/r-sig-geo