Re: [R-sig-Geo] NASA's Black Marble monthly data: Reprojection isn't accurate

2023-09-10 Thread Barry Rowlingson
My gdal 3.4.1 doesn't get the extent. I answered this (badly) on gis.stackexchange - its a 10degree tile where the origin is related to the h and v elements of the path (and also stored as attributes in the netcdf structure). I think I messed up the vertical offset, which was because I only bothe

Re: [R-sig-Geo] Extract CRU data

2023-01-24 Thread Barry Rowlingson
Are you asking if there's a way to automate the download of a list of links from that page? You could write an R script to get the HTML, then find all the HTML tags, and then get the URLs in the link addresses, and there's packages for doing this kind of web scraping. But for this kind of thing i

Re: [R-sig-Geo] Coverting CRS in R to OSGB 1936

2022-11-30 Thread Barry Rowlingson
As I said on gis.stackoverflow, these two things are probably in the same CRS anyway. But also some people have replied suggesting you transform the raster. DONT! (Unless you really have to...). If your raster had been something like 0.5 degree lat-long cells, then transforming it EPSG 27700 (GB g

Re: [R-sig-Geo] Convert geojson file to R

2022-11-29 Thread Barry Rowlingson
Lines('countrymasks.geojson') |> st_read() -> r > > with a warning: > > Warning message: > In readLines("countrymasks.geojson") : > incomplete final line found on 'countrymasks.geojson' > > > On 29/11/2022 00:58, Miluji Sb wrote: >

Re: [R-sig-Geo] Convert geojson file to R

2022-11-28 Thread Barry Rowlingson
This seems to be a weird bug in `st_read`. If you read it with an SQL query that matches every row it works: > js = st_read("./countrymasks.geojson", query="select * from countrymasks > where 1 = 1") Reading query `select * from countrymasks where 1 = 1' from data source `/home/rowlings/Downloads

Re: [R-sig-Geo] Species distribution modeling with presence-only data using log-Gaussian Cox process

2021-02-10 Thread Barry Rowlingson
Before messing with lgcp I'd look at spatstat - lgcp is more intended for relative risk calculations where you have "cases" and "controls", and also for space-time data. spatstat seems to have functions for fitting (and simulating) LGCPs to point patterns so I think that might be what you are afte

Re: [R-sig-Geo] astrophysics - transform sf from equatorial to galactic coordinates

2020-03-22 Thread Barry Rowlingson
Eugene, I don't think this can be done using the PROJ library that does most coordinate transformations for sf objects. The `astrolibR` package has functions for converting coordinates on various astronomical systems https://cran.r-project.org/web/packages/astrolibR/astrolibR.pdf but you have t

[R-sig-Geo] Peter Diggle Birthday Conference

2020-02-25 Thread Barry Rowlingson
Hope nobody thinks I'm spamming the list but I'd like to promote the conference that we are holding in April in honour of Prof Diggle's 70th birthday (actually yesterday). I've worked with him for nearly 30 years, and I wrote the first version of `splancs` for `S` by interfacing to his Fortran cod

Re: [R-sig-Geo] how to get the value of a pixel and its 8 surrounding pixels from points?

2019-11-06 Thread Barry Rowlingson
On Wed, Nov 6, 2019 at 6:18 AM Bede-Fazekas Ákos wrote: > Dear Cristabel, > function focal() of package raster is what you are searching for. > No it isn't. That operates over the whole raster, which is massive overkill for querying the eight pixels around a single point. > > > var <- nc[lon.c

Re: [R-sig-Geo] poly2nb neighbour itself should be considered a neighbour

2019-11-04 Thread Barry Rowlingson
Can you manipulate the adjacency list structure to add `i` to each list element vector? eg using sample data from spdep: make a neighbour structure: > colnn = poly2nb(columbus) this is a list - so for example polygon 4 is next to: > colnn[[4]] [1] 2 3 5 8 2, 3, 5, and 8. It seems you want

Re: [R-sig-Geo] dissolve internal borders of polygons using st_union and group_by

2019-10-17 Thread Barry Rowlingson
Buffering the data by a teeny tiny number of fractional degrees is sufficient to make the edges overlap enough to dissolve properly. Hacky solution, and results in a world that is 0.1 degrees more coastline all round (a negative buffer can correct for this a bit). kk <- aggregate(st_buffer(wor

Re: [R-sig-Geo] CSV with Geometry Column to SF object

2019-10-16 Thread Barry Rowlingson
ects as geometry sdf = st_set_geometry(df, newGeom) 3. (optional) drop the character format column sdf$geom=NULL Now you've got a standard `sf` spatial data frame with the converted geometry. If any of that is wrong I'm sure the real experts here will correct me. Barry On Tue, Oct 15, 20

Re: [R-sig-Geo] CSV with Geometry Column to SF object

2019-10-15 Thread Barry Rowlingson
These strings are hexadecimal WKB geometries. You should be able to turn them back into geometries: > s = "010520D7080100010200039875DF60AC2D4100606296BDAC07410037DB98F1AC2D41001C5EFC79AA074180A23112E1AA2D41001E0E5F18A20741" by constructing a WKB object: > wkb = structur

Re: [R-sig-Geo] Adding a Few Neighbour Relationships to a nb List

2019-08-08 Thread Barry Rowlingson
if I want to add three areas to an area – say I want to add 6,7 and 8 > to the area 10?? > > Please may I have the syntax for that to avoid the integer error?? > > Is this also the root of the error about not being the correct index?? > > Many thanks again, > > Stuart

Re: [R-sig-Geo] Adding a Few Neighbour Relationships to a nb List

2019-08-07 Thread Barry Rowlingson
I recently answered a similar question on Stack Overflow where someone needed to add detached polygons to their connected network by connecting them to their nearest neighbour: https://stackoverflow.com/questions/57269254/how-to-impute-missing-neighbours-of-a-spatial-weight-matrix-queen-contiguity

[R-sig-Geo] FOSS4G UK Conference

2019-07-26 Thread Barry Rowlingson
The UK edition of the leading open source geospatial software conference is happening in Edinburgh in September: https://uk.osgeo.org/foss4guk2019/ there's a few talks with R, but also plenty of opportunity to expand your geospatial knowledge beyond R. Generous sponsorship has meant we have kep

Re: [R-sig-Geo] add a field to sf object and point shape in kml

2019-05-07 Thread Barry Rowlingson
your opinion of using these options vs creating an attribute. > Thanks in advance, > Vijay. > > On Tue, May 7, 2019 at 11:07 AM Barry Rowlingson > wrote: > >> On Tue, May 7, 2019 at 12:54 PM Marta Rufino >> wrote: >> >> > Hi, >> > >&g

Re: [R-sig-Geo] add a field to sf object and point shape in kml

2019-05-07 Thread Barry Rowlingson
On Tue, May 7, 2019 at 12:54 PM Marta Rufino wrote: > Hi, > > Two very simple question: > > 2) > Can we change the polygon col/fill and point shape/col when exporting sf > obejcts to kml, using the function: > st_write(sf.object, " sf.object .kml", driver='kml') > > Setting styles for writing KM

Re: [R-sig-Geo] add a field to sf object and point shape in kml

2019-05-07 Thread Barry Rowlingson
On Tue, May 7, 2019 at 12:54 PM Marta Rufino wrote: > Hi, > > Two very simple question: > > 1) > What is the best way to add a variable (field) to an sf object? > > # For example, if I do: > (a = st_sf(a=1, geom = st_sfc(st_point(0:1 > # I would expect this would work, and it does, but then i

Re: [R-sig-Geo] tpk files

2019-04-12 Thread Barry Rowlingson
On Fri, Apr 12, 2019 at 6:16 PM Marta Rufino wrote: > Hi, > > Now, the next issue will be how to transform the huge world wide sf points > (that are actually 32 classes) into a 'multipolygons' sf. Maybe I should do > a new post with a reproducible example for this new challenge, if I don't > mana

Re: [R-sig-Geo] tpk files

2019-04-11 Thread Barry Rowlingson
ps-3A__www.gdal.org_drv-5Fgeopackage-5Fraster.html&d=DwIGaQ&c=n6-cguzQvX_tUIrZOS_4Og&r=fCPRb7QX-vd5bnO9gIJHCiX852SVUtyYX--xtCKtpfk&m=p5ULiF5de1gKZBP-IzWbMO9Pe5LFzv9uaZ5VJYnWw1Y&s=d6xaKGlN0jpd8mBdjKXAhzst7N3Bgo43BvJlLnDSngk&e= > > > > On 4/11/19, 11:41 AM, "Barry Rowlings

Re: [R-sig-Geo] tpk files

2019-04-11 Thread Barry Rowlingson
What did you try? The instructions at the top say: "Download 3.3GB tile package and rename extension from .tpk to .zip. Extract to get EMU.gpkg" If that's a valid GeoPackage then `sf` should be able to read it. Not sure what might be in the geopackage though, "tile package" sounds like rasters, b

Re: [R-sig-Geo] Aggregating points based on distance

2019-03-13 Thread Barry Rowlingson
On Wed, Mar 13, 2019 at 6:14 PM Andy Bunn wrote: > I would like to create averages of all the variables in a > SpatialPointsDataFrame when points are within a specified distance of each > other. I have a method for doing this but it seems like a silly way to > approach the problem. Any ideas for

Re: [R-sig-Geo] Sampling random directional lines within a polygon

2019-02-06 Thread Barry Rowlingson
Possibly longer optim runs would help or constraining the angles. Anyway, interesting problem Barry On Wed, Feb 6, 2019 at 8:23 PM Barry Rowlingson wrote: > Do you want to generate these for input into some statistical process, or > to generate some test data that looks a bit like real

Re: [R-sig-Geo] Sampling random directional lines within a polygon

2019-02-06 Thread Barry Rowlingson
; two examples of possible lines with 10 segments between > the polygons). > > Thank you very much for you help, > Hannah > > --- > PhD Student |Ecology and Evolutionary Biology > Texas A&M University > > On Wed, Feb 6, 2019 at 5:12 AM Barry Rowlingson < >

Re: [R-sig-Geo] Sampling random directional lines within a polygon

2019-02-06 Thread Barry Rowlingson
[reposting to list after a bounce...] Interesting, but I think we need more details... Do the lines have to start and finish at specific locations in the polygons - like the centroid, or anywhere? So one line might be 3 segments of 10km each connecting two polygon centroids that are 15km apart?

Re: [R-sig-Geo] Leaflet map nested in RShiny App - Improving speed & portability

2018-09-05 Thread Barry Rowlingson
On Wed, Sep 5, 2018 at 12:56 AM, Erin Stearns wrote: > Hello all! > > I hope this message finds you all well! > > I have 2 questions pertaining to the creation of interactive maps via > Leaflet nested inside an RShiny app. One question has to do with > computation while the other has to do with s

Re: [R-sig-Geo] rgdal installation on Fedora 28

2018-06-17 Thread Barry Rowlingson
Just a quick note to point out that you can test installations on systems without having to install such a system by using Docker. Fedora 28 images are available on Docker Hub. You have to figure out how to install the toolchain and other components for building R etc but that helps make a reprodu

Re: [R-sig-Geo] spatio temporal anisotropy: help with stAni argument

2018-05-22 Thread Barry Rowlingson
This question has also been posted to gis.stackexchange.com: https://gis.stackexchange.com/questions/283607/spatio-temporal-anisotropy-in-r-stani-argument-in-vgmst-and-krigest/ and better answers than mine there are welcome... Barry On Tue, May 22, 2018 at 8:39 AM, Dr. Benedikt Gräler wrote:

Re: [R-sig-Geo] Will upcoming ggplot2::calc() clash with raster::calc()?

2018-05-16 Thread Barry Rowlingson
It seems the options are: 1. ggplot2 and raster use calc - scripts will have to use raster::calc or ggplot2::calc to be ambiguous. This is the painful solution. Scripts will break. Users will have to type raster::calc or ggplot2::calc depending on the order they do library(raster);library(ggplot

Re: [R-sig-Geo] Bug in raster::crop?

2018-05-01 Thread Barry Rowlingson
Works perfectly for me, with the same versions of everything: > r <- raster(nrow=45, ncol=90) > r[] <- 1:ncell(r) > e <- extent(-160, 10, 30, 60) > rc <- crop(r, e) > > packageVersion("raster") [1] ‘2.6.7’ > version _ platform x86_64-pc-linux-gnu arch

Re: [R-sig-Geo] Polygon width

2018-04-25 Thread Barry Rowlingson
27;ll certainly try out your alternative solution, based on the > (s)apply function, to see which one is most efficient. > > Thank you so much again, > > PauloFR > > > Às 18:16 de 25-04-2018, Barry Rowlingson escreveu: > > Loop over the row indexes of an sf-class objec

Re: [R-sig-Geo] Polygon width

2018-04-25 Thread Barry Rowlingson
h), so that I can apply it "automatically" to 25,000 > polygons. I am using the rgadl package, but I can switch to sf. > Thanks for any help. > Cheers, > PauloFR > > Às 12:27 de 25-04-2018, Barry Rowlingson escreveu: > > Do you want great-circle distance or is your

Re: [R-sig-Geo] Polygon width

2018-04-25 Thread Barry Rowlingson
Do you want great-circle distance or is your space small enough that you can use planar coordinates? Are your polygons all single rings or are there islands and/or holes? Does that matter? The straightforward way would be to coerce the polygons to points, compute the distance matrix, then take th

Re: [R-sig-Geo] How to create a regular grid?

2018-04-11 Thread Barry Rowlingson
`cell2nb` in spdep will do exactly that: library(sp) library(spdep) plot(cell2nb(5,5),coords=expand.grid(1:5,1:5)) If you want the points as sp class objects, feed SpatialPoints from expand.grid: pts = sp::SpatialPoints(expand.grid(x=1:N,y=1:N)) Barry On Wed, Apr 11, 2018 at 4:31 PM, Rober

Re: [R-sig-Geo] applying a regression kriging model outside gstats

2018-03-20 Thread Barry Rowlingson
On Tue, Mar 20, 2018 at 11:12 AM, Naura, Marc wrote: > Hi, > I have produced a regression kriging model using gstats that I want to > deliver to a wide range of users to predict values for new sites using the > web or as part of a simple computer software (e.g. Visual Basic software). > Is there

Re: [R-sig-Geo] WPS client implementation in R

2018-02-20 Thread Barry Rowlingson
On Tue, Feb 20, 2018 at 3:51 PM, Javier Martínez-López < javi.martinez.lo...@gmail.com> wrote: > You can try OpenCPU (https://www.opencpu.org/). It works great! > I don't see anything WPS there. The advantage of implementing a WPS is that it is then available to anything supporting the WPS standa

Re: [R-sig-Geo] WPS client implementation in R

2018-02-20 Thread Barry Rowlingson
On Tue, Feb 20, 2018 at 3:13 PM, Dr. Benedikt Gräler wrote: > Dear Barry, > > I am not quite sure what you are targetting at: > i) a solution to expose (geo) R functionality as a WPS on the web or > ii) a R package to ease the access to an exposed WPS. > > Regarding i), there is WPS4R (as a follo

[R-sig-Geo] WPS client implementation in R

2018-02-20 Thread Barry Rowlingson
I'm wondering what's the state of WPS (Web Processing Service) client implementations in R? All I can find are the abstract of a 2008 UseR! talk: https://www.r-project.org/conferences/useR-2008/abstracts/Henneboehl+Pebesma.pdf and what looks like code designed to call a custom WPS server in the G

Re: [R-sig-Geo] Save plot as Geotiff

2018-02-07 Thread Barry Rowlingson
I'd do this by saving the image on the graphics device as a PNG, then creating a "world" file (with extension PNGW) from the coordinates of the corners and the resolution of the PNG. This is a six line text file with sufficient information to georeference a grid. That's enough for `gdal` to underst

Re: [R-sig-Geo] comparing one raster to a stack and condition

2017-12-14 Thread Barry Rowlingson
Here's a way - first let's make some sample data in a stack: maker = function(d){raster(matrix(runif(16),4,4))} rains = stack(lapply(1:10, maker)) so `rains` is a stack of 10 4x4 rasters with random numbers in. Now the raster we want to test: r1 = maker() Okay, all set up. We have a raster a

Re: [R-sig-Geo] format. adm

2017-12-07 Thread Barry Rowlingson
ments trying to describe the ADM format seem to say it is a bit hard to understand with variants changing substantial parts of the structure - I suspect something like that has caused the problematic conversion experienced. Barry On Tue, Dec 5, 2017 at 3:55 PM, Barry Rowlingson < b.rowling...@lanc

Re: [R-sig-Geo] format. adm

2017-12-05 Thread Barry Rowlingson
There's a converter on sourceforge that claims it can convert adm to gpx, and you can read gpx with rgdal: https://sourceforge.net/projects/adm2gpx/ 2017-12-05 15:45 GMT+00:00 Mauricio Mardones Inostroza < mauricio.mardo...@ifop.cl>: > Dear group > > Do you know some routine to transform .adm

Re: [R-sig-Geo] format. adm

2017-12-05 Thread Barry Rowlingson
Do you have a sample file you could share? I've tried a quick internet search, and nothing sticks out. There seems to have been one effort about seven years ago that died out: http://gpsbabel.2324879.n4.nabble.com/Garmin-ADM-file-format-td3588.html If you have a typical file and you know roughly

Re: [R-sig-Geo] Is the raster package still receiving updates?

2017-10-22 Thread Barry Rowlingson
Here's what I think should happen: Robert Hijmans lets us know what his vision of raster is, and how he plans to support it. He should say if he wishes to carry on as maintainer or not. If not, we need a new maintainer and then we can think about moving development to gitlab, or whatever. Barr

Re: [R-sig-Geo] buffer from dismo package error

2017-10-01 Thread Barry Rowlingson
This has been cross-posted to gis.stackexchange.com if people want to tackle it there: https://gis.stackexchange.com/questions/257175/buffer-from-points-using-dismo-r Barry On Sun, Oct 1, 2017 at 10:32 PM, Sergio A Estay wrote: > Hi everybody, > > I am trying to create a buffer around severa

Re: [R-sig-Geo] Compile sf in windows with liblwgeom

2017-09-16 Thread Barry Rowlingson
On Sat, Sep 16, 2017 at 3:45 PM, Edzer Pebesma < edzer.pebe...@uni-muenster.de> wrote: > > > On 16/09/17 15:20, Eduardo Diez wrote: > > Dear list, > > I have a MULTIPOLYGON geometry set where the rings are in the wrong > > direction and would like to correct that with *st_make_valid*. As I'm in >

Re: [R-sig-Geo] [FORGED] circular spatial polygon

2017-09-13 Thread Barry Rowlingson
Your question is still a tiny bit imprecisely defined, since you haven't said how you want this polygon to align to the axes. This function computes the coordinates of an N-sided regular polygon centred at (x,y) of radius r, of n sides, at angle theta: ngon = function(x,y,r,n,theta){ phi = seq(t

Re: [R-sig-Geo] ISO3 to 7 continents names

2017-09-08 Thread Barry Rowlingson
On Thu, Sep 7, 2017 at 7:35 PM, Miluji Sb wrote: > Dear all. > > Is it possible to convert.identify iso3 country names to the seven > continent names? > > # Asia, Africa, Antarctica, Australia, Europe, South America, and North > America, > > I have tried the following: > > ### > region <- merge(c

Re: [R-sig-Geo] Order a SpatialLine passes through a SpatialPolygons

2017-09-01 Thread Barry Rowlingson
Slightly hacky method: sample lots of points along the line, over() the points with the polygons, returns polygon IDs in order: > unique(over(spsample(the.line,1,"regular"),as(columbus,"SpatialPolygons"))) [1] 21 24 25 26 22 if the line goes back into a polygon with the same ID you'll see tha

Re: [R-sig-Geo] average bearing of animal movement data

2017-08-03 Thread Barry Rowlingson
You can convert a "trip" object to a SpatialPointsDataFrame with as("SpatialPointsDataFrame",my_trip). Then you can use functions like "spDistsN1" from sp to compute the distance from "home" to each point, find the maximum, and then use "bearing" from the "geosphere" package to get the bearing for

Re: [R-sig-Geo] Paired (before-after comparison) t-test with spatial locations

2017-06-24 Thread Barry Rowlingson
The classic t-test is something like "are boys taller than girls?". Throw the boy's heights and the girl's heights into `t.test` and out comes an answer (and a p-value). Now suppose you want to add a covariate? Are these boys taller than these girls, accounting for any difference in their parent's

Re: [R-sig-Geo] Google Earth Engine?

2017-05-26 Thread Barry Rowlingson
On Fri, May 26, 2017 at 11:34 PM, Andy Bunn wrote: > Does anybody out there interface with the google earth engine from R? I'm too > old a dog to learn python. -Andy Too old? Never! See: https://www.xkcd.com/353/ Given that the other supported option is Javascript I suspect a solution usin

Re: [R-sig-Geo] after running as.ppp(), all points lying outside the window

2017-04-05 Thread Barry Rowlingson
On Wed, Apr 5, 2017 at 8:27 AM, Musa, Kamarul Imran wrote: > str_typ2 <- as.ppp(str_typ, W = Win) as.ppp is using the first two columns of your data frame for coordinates, the first one in yours is the mark! So you have: > str_typ = data.frame(mark=sample(2,1135,TRUE), x=runif(1135,388992, 503

Re: [R-sig-Geo] Error in bbox(newdata) : object not a >= 2-column array

2017-03-11 Thread Barry Rowlingson
On Sat, Mar 11, 2017 at 12:38 PM, wrote: > Dear R-Users, > Please anyone to help me with this error: > > kriged=krige(Nmin~1,locationsDD,grid,model=vgm(1,"Exp",150,1)) > Error in bbox(newdata) : object not a >= 2-column array > > Thank you so much in advance! Hard to debug without your data. Th

Re: [R-sig-Geo] "invalid" geometries in shape data

2017-02-08 Thread Barry Rowlingson
Searching GIS StackExchange for [r] and TopologyException might find you a few: http://gis.stackexchange.com/search?q=%5Br%5D+topologyexception [answered one of these just today: http://gis.stackexchange.com/questions/227569/r-error-fortifying-dataframe-from-shapefile] Barry On Tue, Feb 7, 2017

Re: [R-sig-Geo] getData returns status 403

2017-01-30 Thread Barry Rowlingson
On Sun, Jan 29, 2017 at 7:26 PM, Loïc Dutrieux wrote: > world <- getData(name = 'countries') The world countries file download function has a hardcoded version in it: > raster:::.countries function (download, path, ...) { filename <- paste(path, "countries.RData", sep = "") if (!file.exi

Re: [R-sig-Geo] display location on google earth

2016-12-29 Thread Barry Rowlingson
You made a couple of little mistakes! See below: On Thu, Dec 29, 2016 at 5:51 PM, Felipe Carrillo via R-sig-Geo wrote: > Hi;I have a shapefile named 'Wolf' that I can display in google with the > following code: # Show the shapefile on top of google > writeOGR(Wolf, "Wolf.kml", "Wolf", driver=

Re: [R-sig-Geo] Plotting simple features sf with ggplot2

2016-12-08 Thread Barry Rowlingson
able to say > what the experiment died of. ~ Sir Ronald Aylmer Fisher > The plural of anecdote is not data. ~ Roger Brinner > The combination of some data and an aching desire for an answer does not > ensure that a reasonable answer can be extracted from a given body of data. > ~ John T

Re: [R-sig-Geo] Plotting simple features sf with ggplot2

2016-12-08 Thread Barry Rowlingson
On Wed, Dec 7, 2016 at 10:43 PM, Michael Sumner wrote: > I think there is now a majority opinion that fortify is not such a good > idea for simple feature (or in general: spatial) geometries. > > > It's not a great idea, but you can do it and it already works. It works, for some values of "works

Re: [R-sig-Geo] apply() proj4string to list of rasters

2016-11-01 Thread Barry Rowlingson
You can do it by rewriting `projection(r) <- Z` as a function, and assigning it back to the same name. I think this captures the essence: Two rasters with default projections (epsg:4326) > r1 = raster() > r2 = raster() Loop over names, get, set projection, re-assign: > for(rname in c("r1","r

Re: [R-sig-Geo] DEM plot3D and overlay an aerial image

2016-10-03 Thread Barry Rowlingson
On Mon, Oct 3, 2016 at 10:38 AM, Mathieu Rajerison wrote: > Hi R-List, > > > I have a DEM on one hand, and on the other hand, I have an RGB aerial image > > I tried rasterVis and plot3D function, but I didn't find how to use the > colors of my RGB aerial image. from the help for plot3D: drape:

Re: [R-sig-Geo] Plotting 2 rasters over each other on a map with 2D colour scheme

2016-09-22 Thread Barry Rowlingson
Another way of visualising two values per pixel is to vary two of Hue, Luminance, and Saturation. You can even use all three if you have three variables! Note that Hue is a circular variable, and in the example I saw it was being used to map the seasonal peak of rainfall, so a circular variable wa

Re: [R-sig-Geo] My code mistakenly prints multiple PDF pages

2016-09-11 Thread Barry Rowlingson
Jim, have you fixed this? There's a lot to look at here and is hard to see what is going on because most of it is probably irrelevant to your problem, and we can't run your code because we don't have your data or shapefiles. But if you run this with a screen device, does it put all the plots on

Re: [R-sig-Geo] How to do square buffers around spatial points

2016-08-25 Thread Barry Rowlingson
c(w,w))}),2,function(v){Polygons(list(Polygon(matrix(v,ncol=2,byrow=TRUE))),ID=runif(1))})) > plot(polys) > plot(d,add=TRUE) Barry On Thu, Aug 25, 2016 at 2:11 PM, Barry Rowlingson wrote: > 2016-08-25 13:01 GMT+01:00 Manuel Spínola : >> Dear list members, >> >> H

Re: [R-sig-Geo] How to do square buffers around spatial points

2016-08-25 Thread Barry Rowlingson
2016-08-25 13:01 GMT+01:00 Manuel Spínola : > Dear list members, > > Ho can I do square buffers around spatial points? Break it down: 1. For each point compute the coordinates of the four corners of the square by adding half the width of your square. 2. Construct a Polygon from those four points

Re: [R-sig-Geo] A Qgis Map Graphics Device for R

2016-08-18 Thread Barry Rowlingson
On Thu, Aug 18, 2016 at 1:17 PM, Manuel Spínola wrote: > Dear Barry, > > How I install the package? With difficulty... First you probably need to be running Linux and have Qgis 2.14 or higher installed. Install the rPython package into R - install.packages("rPython") may work, or may need yo

[R-sig-Geo] A Qgis Map Graphics Device for R

2016-08-17 Thread Barry Rowlingson
Time to announce my little summer side project... `pqgisr` is a *highly* experimental package to provide an easy way for R programmers to use the cartographic features of Qgis without the hassle of exporting objects, loading them into Qgis, and then having to style them. The package provides func

Re: [R-sig-Geo] Geographically weighted regression on categorical variable

2016-07-19 Thread Barry Rowlingson
I don't think the point pattern analysis will help you at all - your sampling locations aren't a point pattern (although they form a pattern of points) - their location has been decided by whoever decided where to take the samples. Point pattern analysis is appropriate where you are interested in t

Re: [R-sig-Geo] Announcing the R Shapefile Contest

2016-07-13 Thread Barry Rowlingson
On Wed, Jul 13, 2016 at 4:22 PM, wrote: > Hi everyone, > > I wanted to let people here know that I am sponsoring the "R Shapefile > Contest": > > http://www.arilamstein.com/blog/2016/07/12/announcing-r-shapefile-contest/ > > For the last few years I've done a lot of work with creating choropleth

Re: [R-sig-Geo] How to create an ellipse buffer using SpatialPointsDataFrame?

2016-06-29 Thread Barry Rowlingson
On Wed, Jun 29, 2016 at 2:26 AM, Isaque Daniel wrote: > Hi everyone, > > > I have been working in a model for spatial analysis and my problem now is > generate some ellipses around of SpatialPointsDataFrame. > > > I looking for some similar gBuffer of rgeos, but until now I can't find a > soluti

Re: [R-sig-Geo] RQGIS - integrating R with QGIS

2016-06-19 Thread Barry Rowlingson
Jannes, did you consider using the rPython package? Its easy enough to import qgis functionality, there's less overhead since you aren't spawning a new python/qgis session for every command, you can save state between python calls, and you hand-off the platform dependency to that package. Barry

Re: [R-sig-Geo] Mask a map using statistical significance

2016-05-04 Thread Barry Rowlingson
Your example looks a bit rubbish because you have mostly isolated pixels. Let's make an example with an area so we can see the shading. > r.pvalue = raster(outer(-24:25,-24:25, function(a,b){a^2+b^2})/12) > range(r.pvalue[]) [1] 0. 0.01041667 now convert your raster to polygons at the

[R-sig-Geo] OSGeo UK event

2016-04-22 Thread Barry Rowlingson
The UK Chapter of OSGeo is holding a FOSS4GUK conference in Southampton in June. I am quite confident there will be at least one workshop on mapping in R there. We're taking proposals for talks and workshops, and also early bird tickets - the web site is here: http://uk.osgeo.org/foss4guk2016/

Re: [R-sig-Geo] Links to Zika virus paper

2016-04-21 Thread Barry Rowlingson
On Thu, Apr 21, 2016 at 8:19 AM, Roger Bivand wrote: > Why we do what we do: > > Congratulations to Robert Hijmans and others maintaining the dismo package: > > https://cran.r-project.org/web/packages/dismo/index.html > > which is the computational basis for: > > http://elifesciences.org/content/5

Re: [R-sig-Geo] Drawing the maximum-area rectangle in a non-convex polygon

2016-04-14 Thread Barry Rowlingson
write code to pass the options into the JS, pull requests are welcome. I'm not sure what the license on the coffee script code is, I think its BSD, which means its okay to use this like this. Will investigate. Incidentally, the V8 package is a very slick interface to JS from R. Impressed.

Re: [R-sig-Geo] Drawing the maximum-area rectangle in a non-convex polygon

2016-04-13 Thread Barry Rowlingson
On Tue, Apr 12, 2016 at 10:48 PM, Tiernan Martin wrote: > Hi Barry – > > Are you referring to the javascript code detailed here: > http://d3plus.org/assets/posts/largestRect/src/largestRect.coffee ? > > I don't know much about running javascript in R, but I would be willing to > give it a shot for

Re: [R-sig-Geo] Drawing the maximum-area rectangle in a non-convex polygon

2016-04-12 Thread Barry Rowlingson
Could you simply use the Javascript code in that web page via one of the R-Javascript interface packages? On Tue, Apr 12, 2016 at 8:42 PM, Tiernan Martin wrote: > Does anyone know if there is an R package out there with an algorithm which > finds the maximum-area rectangle that can fit within a n

Re: [R-sig-Geo] Find a circle center with spatial points

2016-03-19 Thread Barry Rowlingson
>> the above input yields >> >> initial circle: -001.69467803 -000.69446643 006.23578103 >> converged after 7 iterations >> final circle: -001.34339845 -001.34426151 006.44308386 >> with the format x,y,radius >> >> which at least make sense with respe

Re: [R-sig-Geo] Find a circle center with spatial points

2016-03-19 Thread Barry Rowlingson
On Fri, Mar 18, 2016 at 6:49 PM, Chris Reudenbach wrote: > Because it seems to be an arc and not a circle issue that you can solve the > problem by > picking arbitrary two points of your assumed "arc" then construct > (calculate) the perpendicular bisector of > the line between them and do so for

Re: [R-sig-Geo] Find a circle center with spatial points

2016-03-18 Thread Barry Rowlingson
On Fri, Mar 18, 2016 at 2:43 PM, Alex Mandel wrote: > library(rgeos) > gCentroid > > http://www.rdocumentation.org/packages/rgeos/functions/topo-unary-gCentroid > > Assuming its a circle that would be the center. Only if you have points uniformly (or uniform-randomly) distributed round the full e

Re: [R-sig-Geo] Plotting Kernel results with ggplot2

2016-02-29 Thread Barry Rowlingson
I think you will have to take off the ggplot2 training wheels and do it another way. Here's the outline: 1. Use kde2d to compute your kernel on a grid - you'll have to choose the bandwidth and grid size, ggplot2 usually makes those decisions for you. Something like: k = kde2d(xy.df$x, xy.df$y,h=0

Re: [R-sig-Geo] resolution of openmap() raster layers

2016-02-25 Thread Barry Rowlingson
On Thu, Feb 25, 2016 at 5:11 PM, Agustin Lobo wrote: > Is there any way to download the raster layers > of openmap() with an increased resolution? > I find the quality of the labels very low, > or am I doing something wrong? i.e. > > require(raster) > require(mapmisc) > nica <- getData("GADM", cou

Re: [R-sig-Geo] Single side buffer in R

2015-12-31 Thread Barry Rowlingson
What's happened here is that part of the RHS of the buffer (from the acute angle segment) has wrapped round so far that it has overlapped with the LHS of the buffer from the first segment. So there's an area which is both on the LHS of the line and the RHS. What do you want it to be? You could jus

Re: [R-sig-Geo] Prepping data for FlexScan

2015-12-29 Thread Barry Rowlingson
FlexScan seems to be distributed as a closed-source Windows-binary only piece of software: https://sites.google.com/site/flexscansoftware/home which raises lots of "avoid at all costs" red flags for me. The methodology is published and could be re-implemented as an R package by a smart enough pr

Re: [R-sig-Geo] save SpatialPolygonsDataFrame as dxf file

2015-12-01 Thread Barry Rowlingson
ogr2ogr on the command line does a better job. Having saved the square as a shapefile I can do this: $ ogr2ogr -f "DXF" output.dxf foo.shp ERROR 1: DXF layer does not support arbitrary field creation, field 'Foo' not created. - an error, but a file is created with features in it... ogrinfo tells

Re: [R-sig-Geo] Adding spatial tables to existing SpatiaLite DBs

2015-11-03 Thread Barry Rowlingson
On Tue, 3 Nov 2015, Roger Bivand wrote: > >> On Tue, 3 Nov 2015, Barry Rowlingson wrote: >> >>> I don't think what I'm trying to do is "appending". I'm trying to >>> write two spatial data tables with different names in the single >&

Re: [R-sig-Geo] Adding spatial tables to existing SpatiaLite DBs

2015-11-02 Thread Barry Rowlingson
;, layer_option="FORMAT=SPATIALITE") Interestingly when I try and write with the *same* table name, rgdal helpfully suggests "layer exists, use a new layer name", but when I obey, I get the error behaviour I've described Barry On Mon, Nov 2, 2015 at 11:21 PM, Roge

[R-sig-Geo] Adding spatial tables to existing SpatiaLite DBs

2015-11-02 Thread Barry Rowlingson
I can create a SpatiaLite DB file and put a layer in it, but if I try and add another layer, rgdal fails. Example: Versions etc: > require(rgdal) Loading required package: rgdal Loading required package: sp prgdal: version: 1.0-7, (SVN revision 559) Geospatial Data Abstraction Library extension

Re: [R-sig-Geo] Plot one character on a spatial map

2015-10-18 Thread Barry Rowlingson
On Sun, Oct 18, 2015 at 9:33 PM, Jim Burke wrote: > I would like to plot a cex(17) darkgreen triangle at a specific lat/long > spatial map on an existing plot. Or a star at that location. > > How might I approach this? > > I saw an example (below) but so much like the internet not how to > impleme

Re: [R-sig-Geo] problems for reading ASCII file

2015-10-07 Thread Barry Rowlingson
On Wed, Oct 7, 2015 at 10:04 AM, Paulo Flores Ribeiro wrote: > Try change cell size in your ascii text file (eg. instead of «cellsize > 0,0012386489974299», try «cellsize 10,10») How is that going to do anything but break the geolocation of the raster? I'm worried about the comma decimal separa

Re: [R-sig-Geo] Zip Code Data

2015-10-01 Thread Barry Rowlingson
What do you mean by "cluster"? Aren't zip codes clustered more in urban areas than rural anyway? What's the question you want answered about the data? There should be something in the spatial statistics realm that can help you, but figuring out exactly what is the tricky bit... Barry On Thu, Oc

Re: [R-sig-Geo] Quickest way to tell if an arbitrary file is a raster/vector?

2015-06-02 Thread Barry Rowlingson
Tricky, because OGR (at least) doesn't have a 1-1 mapping of "file" to "data source" * I think any component of a shapefile can be used as a data source of a single-layer. Command-line ogrinfo on my machine thinks so: $ ogrinfo DSMW.dbf INFO: Open of `DSMW.dbf' using driver `ESRI Shapef

[R-sig-Geo] Javascript All The Things!

2015-05-29 Thread Barry Rowlingson
[Apologies for the memey subject: http://knowyourmeme.com/memes/x-all-the-y] Developers can't fail to have noticed the rise of Javascript, both in the browser and outside of it. But it has now crept into R, and into R-spatial packages. Javascript, like most languages, has its right to exist and i

Re: [R-sig-Geo] Replace a polygon by a new one of a SpatialPolygonsDataFrame

2015-05-12 Thread Barry Rowlingson
This works: create a new SpatialPolygonsDataFrame with just your new geometry, copying the data from the old geometry, and then use cbind and selection to create a new object: theNew <- list(Polygons(list(Polygon(cbind(c(r[1,1],r[1,1],r[1,2],r[1,2],r[1,1]),c(r[2,1],r[2,2],r[2,2],r[2,1],r[2,1]

Re: [R-sig-Geo] Issue with ogrInfo

2015-05-11 Thread Barry Rowlingson
On Mon, May 11, 2015 at 11:52 AM, Roger Bivand wrote: > On Mon, 11 May 2015, Barry Rowlingson wrote: > >> If you go far enough into the file (which appears to be without line >> breaks, so somewhere on line 1... You'll see: >> >> "arcs":[[[7533,1255]

Re: [R-sig-Geo] Issue with ogrInfo

2015-05-11 Thread Barry Rowlingson
ot;OGRGeoJSON" with 632 features and 3 fields Feature type: wkbPolygon with 2 dimensions H Barry On Sun, May 10, 2015 at 6:38 PM, Roger Bivand wrote: > On Sun, 10 May 2015, Barry Rowlingson wrote: > >> On Sun, May 10, 2015 at 4:31 PM, Daniel Marcelino >> w

Re: [R-sig-Geo] Issue with ogrInfo

2015-05-10 Thread Barry Rowlingson
On Sun, May 10, 2015 at 6:12 PM, Barry Rowlingson wrote: > Solution is usually "use gdal/ogr tools to convert to plain old > geojson (ogr2ogr)" Actually that's a really stupid solution. If ogr2ogr can do it, you need the support in the first place! Doh! You need a sep

Re: [R-sig-Geo] Issue with ogrInfo

2015-05-10 Thread Barry Rowlingson
On Sun, May 10, 2015 at 4:31 PM, Daniel Marcelino wrote: > Dear all, I'm having the following issue when trying to read a > topographical json file: That's a **topological** (not topographical) geojson file. Instead of recording each polygon separately, and thus duplicating common boundaries, a

Re: [R-sig-Geo] Interactive maps

2015-04-29 Thread Barry Rowlingson
On Wed, Apr 29, 2015 at 2:36 PM, Antonio Serrano via R-sig-Geo wrote: I suspect we may need some clarification... > I have a map which has been produced by a Fortran program. I have the > sources of this Fortran program and can produce the map in many formats: eps, > ps, png, jpeg, svg, et

  1   2   3   4   5   >