Re: [R-sig-Geo] Accurate spatial database for country administrative boundaries

2020-12-02 Thread Bacou, Melanie
See also FAO GAUL 2015 Edition (is the latest I blieve): https://geonode.wfp.org/layers/geonode%3Aadm1_gaul_2015 And the UN Humanitarian Data Exchange for all latest official country boundaries: https://data.humdata.org/ --Mel. On

Re: [R-sig-Geo] How to change scale labeling in spplot

2020-08-10 Thread Bacou, Melanie
Tom, Try something like that: spplot(raster, at=1:3,   col.regions=c(col1, col2, col3),   colorkey=list(labels=list(labels=c("Af", "Am", "Aw"), at=1:3+.5))) Else use package `tmap` (friendlier interface). --Mel. On

[R-sig-Geo] Use raster::getData to access long term bioclimatic RFE CHIRPS ERA5?

2019-05-17 Thread Bacou, Melanie
Dear List, I am a long term user of raster::getData to easily retrieve historical time-series from WorldClim. Is there a plan (or separate R packages) to extend this feature to other bioclimatic datasets, in particular: - USGS RFE v2.0

Re: [R-sig-Geo] Issues with a GDB file in R?

2018-05-03 Thread Bacou, Melanie
Cotton, Why use the ESRI format? Will be much easier to download the GeoTIFF rasters and raster::extract() to conduct your analysis. --Mel. On 05/02/2018 02:56 PM, Cotton Rockwood wrote: Hi Roman - As far as I know, 'readOGR' does

Re: [R-sig-Geo] help needed regarding package OSRM

2017-11-07 Thread Bacou, Melanie
This works for me (`f` is a data.frame of X,Y origin locations, `t` is a data.frame of X,Y destinations): osrm_api <- function(f, t, key=NULL) {   url <- "https://router.project-osrm.org/table/v1/driving/"   url <- paste0(url,     paste(f$X,

Re: [R-sig-Geo] sampling a raster within a polygon

2017-10-24 Thread Bacou, Melanie
Sorry the exact code is: xy.r <- extract(r, xy.sp) xy.r.sample <- lapply(xy.r, sample, 10) On 10/24/2017 01:34 PM, Bacou, Melanie wrote: Andy, Simple use `extract()` instead of `mask()`, and then randomly sample

Re: [R-sig-Geo] sampling a raster within a polygon

2017-10-24 Thread Bacou, Melanie
Andy, Simple use `extract()` instead of `mask()`, and then randomly sample cells in each polygon. Should be much faster, e.g.: xy.r <- extract(r, xy.sp) xy.r.sample <- lapply(xy.r, sample.int, n=10) --Mel. On 10/23/2017 12:57 PM, Andy Bunn

Re: [R-sig-Geo] WorldClim Version2

2017-09-27 Thread Bacou, Melanie
I would assume `raster::getData("worldclim", ...)` uses WorldClim version 2? --Mel. On 09/25/2017 05:14 PM, Andy Bunn wrote: Great. Thanks Marcelino. I have all the data dowloaded. I'm surprised that there isn't a dedicated package for

Re: [R-sig-Geo] Square vs. honeycomb raster grids

2017-09-02 Thread Bacou, Melanie
://www.sciencedirect.com/science/article/pii/S0304380007001949 best wishes, Rafael H M Pereira On Fri, Sep 1, 2017 at 11:42 AM, Bacou, Melanie <m...@mbacou.com> wrote: On 09/01/2017 03:53 AM, Roger Bivand wrote: On Fri, 1 Sep 2017, Bacou, Melanie wrote: I am wondering if current R

Re: [R-sig-Geo] Square vs. honeycomb raster grids

2017-09-01 Thread Bacou, Melanie
On 09/01/2017 03:53 AM, Roger Bivand wrote: On Fri, 1 Sep 2017, Bacou, Melanie wrote: I am wondering if current R raster operations (e.g. `extract()`, `resample()`, distance(), etc.) can be modified to work with honeycomb

[R-sig-Geo] Square vs. honeycomb raster grids

2017-09-01 Thread Bacou, Melanie
I am wondering if current R raster operations (e.g. `extract()`, `resample()`, distance(), etc.) can be modified to work with honeycomb (hexagonal) grids instead of simple square grids? This is driven by e.g. work at Uber

Re: [R-sig-Geo] split SLDF with attributes

2017-02-24 Thread Bacou, Melanie
p the attributes. > Option2) rgeos:over I know this tool, but O have several lines > crossing among them. I am afraid, that can be a bit messy. > I doesn't know the gTouches...I check it after your suggestion.. > But I think the rgeos:Over os the best option for me. > Thanks for

Re: [R-sig-Geo] split SLDF with attributes

2017-02-23 Thread Bacou, Melanie
Marta, Option 1) using CreateSegments() seems to do what you want. Why don't you simply use rgeos::over() or rgeos::gTouches() between your old and new SLDFs to match the index positions of your old attributes to your new segments? --Mel. On 2/23/2017 2:27 PM, marta azores wrote: Hi all,

Re: [R-sig-Geo] Package to download Landsat images

2017-02-12 Thread Bacou, Melanie
I have not tested yet, but there is an R package to interact with 2 NASA APIs: - Earth Observatory Natural Event Tracker (EONET) web service - Earth Imagery API and Earth Imagery Assets API (Landsat8) https://github.com/Eflores89/nasadata http://www.gis-blog.com/nasadata/ --Mel. On 2/11/2017

Re: [R-sig-Geo] Elevation data

2017-01-12 Thread Bacou, Melanie
R raster::getData("SRTM", ...) will return elevation rasters at 90m resolution. See: https://www.rdocumentation.org/packages/raster/versions/2.5-8/topics/getData http://www.cgiar-csi.org/data/srtm-90m-digital-elevation-database-v4-1 --Mel. On 1/11/2017 6:26 AM, Miluji Sb wrote: Dear

[R-sig-Geo] Generate CDL (metadata) for NetCDF files?

2016-11-13 Thread Bacou, Melanie
Hi, I need to generate a large series of NetCDF files (over 800) and I'm trying to follow good metadata practices per http://www.unidata.ucar.edu/software/netcdf/examples/files.html. Could some of you suggest an approach to: 1) add projection information to .nc files (using

Re: [R-sig-Geo] Extract() fails to return data for boundary admin units

2016-10-18 Thread Bacou, Melanie
Chris, Actually I take that back, using extract() with `weights=TRUE` returned `0` instead of NA values for these problematic coastal admin units. Think I might have to impute them manually. --Mel. On 10/18/2016 2:33 PM, Bacou, Melanie wrote: > > Chris, > Thanks, using `wei

Re: [R-sig-Geo] Extract() fails to return data for boundary admin units

2016-10-18 Thread Bacou, Melanie
r::extract it looks like you want to employ the > weights are if your polys are relatively smaller than your cells. > > HTH > Chris > > > On Oct 18, 2016 4:35 PM, "Bacou, Melanie" <m...@mbacou.com > <mailto:m...@mbacou.com>> wrote: > > Hi, >

[R-sig-Geo] Extract() fails to return data for boundary admin units

2016-10-18 Thread Bacou, Melanie
Hi, I'm summarizing biophysical rasters (UDEL precipitation and temperature) across administrative units for countries in Africa using (pseudo code): raster::extract(udel, admin, fun=mean, na.rm=T, small=T) Out of the 756 units I need data for, extract() fails to return means for a few

Re: [R-sig-Geo] Global potential natural vegetation at 1km?

2016-09-30 Thread Bacou, Melanie
In addition, you could also take a look at IIASA global data: http://www.iiasa.ac.at/web/home/research/modelsData/models-tools-data.html --Mel. Hi, About Vegetation can you use the Tree Cover map, develop by Hansen team. They use Landsat data to identify the tree cover coverage. The research

Re: [R-sig-Geo] rasterVis, multiple plots and scalebar labels

2016-09-23 Thread Bacou, Melanie
Here is a stump that might also work with levelplot(): # Plot raster with no scalebar first raster::plot(r, col=vector_of_colors, legend=FALSE, axes=FALSE) # Add a custom scalebar raster::plot(r, legend.only=TRUE, col=vector_of_colors, axis.args=list(at=1:length(vector_of_labels),

Re: [R-sig-Geo] mapview 1.2.0

2016-09-20 Thread Bacou, Melanie
l at http://environmentalinformatics-marburg.github.io/mapview/introduction.html which has all the details. HTH Tim On 20.09.2016 11:06, Bacou, Melanie wrote: Tim, Both `leaflet` and `tmap` currently offer quick interactive visualization of geospatial data in R. Does `mapview` provide different fun

Re: [R-sig-Geo] mapview 1.2.0

2016-09-20 Thread Bacou, Melanie
Tim, Both `leaflet` and `tmap` currently offer quick interactive visualization of geospatial data in R. Does `mapview` provide different functionality at this point? https://rstudio.github.io/leaflet/ https://cran.r-project.org/web/packages/tmap/vignettes/tmap-nutshell.html Thx, --Mel. On

Re: [R-sig-Geo] Leaflet and R - web map

2016-08-29 Thread Bacou, Melanie
Jaya, Have a look through the `leaflet` and `tmap` package documentation. There are examples there. --Mel. On 8/29/2016 7:51 PM, Jaya Krishnan wrote: HI, I've been trying to make an interactive web map using leaflet package in R. Just have a couple of issues. 1. Is it possible to get a

Re: [R-sig-Geo] How to resample a map using the statistical mode of class to fill the new pixel

2016-08-28 Thread Bacou, Melanie
Sorry I meant reproject using nearest neighbor: projectRaster(from, to, method="ngb") On 8/28/2016 2:37 AM, Bacou, Melanie wrote: Isaque, If your LandScan raster is at 30m resolution, then best might be to `aggregate()` to as close as 250m (e.g. using `fact=8` or `fact=9` and

Re: [R-sig-Geo] How to resample a map using the statistical mode of class to fill the new pixel

2016-08-28 Thread Bacou, Melanie
saggregate to greatest common factor (5 > or 10m) cells first, then aggregate up to 250m MODIS. With mode on > categorical data, that should still give you your expected results; > with continuous raster values and other functions, it might not be > appropriate. > > Tom 2 >

Re: [R-sig-Geo] How to resample a map using the statistical mode of class to fill the new pixel

2016-08-26 Thread Bacou, Melanie
Isaque, check this thread on StackExchange: http://gis.stackexchange.com/questions/177423/r-aggregate-raster-with-mode-function-how-does-it-work --Mel. On 8/26/2016 10:07 PM, Isaque Daniel wrote: > Hi dear all, > > > I need to resample a tree cover map create by Landsat imagery to the MODIS >

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

2016-08-18 Thread Bacou, Melanie
Barry, This looks great. Til now I've been using `tmap` (with leaflet) to explore spatial data interactively and to print maps within R, but a QGIS widget offers interesting options for creating and re-using styles. What about editing features within the widget as well (e.g.

Re: [R-sig-Geo] How to calculate seasonal means in raster time series?

2016-08-16 Thread Bacou, Melanie
Maybe create a function that takes a date as input and returns a meteorological season, and pass this function to `zapply(by=fun)`. --Mel. On 8/16/2016 8:38 PM, Thiago V. dos Santos via R-sig-Geo wrote: Dear all, I am using the raster package to calculate seasonal averages of climatic

Re: [R-sig-Geo] Climate data in R

2016-08-02 Thread Bacou, Melanie
I also recommended browsing through NOAA PSD curated catalog. I believe it's up-to-date and provide useful metadata and links to original sources: http://www.esrl.noaa.gov/psd/data/ --Mel. On 8/2/2016 5:34 PM, Tom Philippi wrote: Without knowing what part of the globe you need climate data

Re: [R-sig-Geo] Country names from coordinates

2016-07-25 Thread Bacou, Melanie
Here is an approach using raster::extract(). I assume your point locations are unprojected. library(raster) library(tmap) data(World) proj4string(World) # [1] "+proj=eck4 +lon_0=0 +x_0=0 +y_0=0 +ellps=WGS84 +datum=WGS84 +units=m +no_defs +towgs84=0,0,0" pts <- SpatialPointsDataFrame(temp [,

Re: [R-sig-Geo] Problems with rbind(list(), makeUniqueIDs=T)

2016-07-24 Thread Bacou, Melanie
getData("GADM", country=x, level=1)) m <- do.call(bind, m) Robert On Sat, Jul 23, 2016 at 4:10 AM, Bacou, Melanie <m...@mbacou.com> wrote: Edzer, Rolf, Many thanks for the clarification! Just to confirm that Rolf's `do.call()` example works for me using the latest GitHub commi

Re: [R-sig-Geo] Problems with rbind(list(), makeUniqueIDs=T)

2016-07-23 Thread Bacou, Melanie
>> On 7/22/2016 5:53 PM, Edzer Pebesma wrote: >>> The correct call to rbind would be >>> >>> mm = rbind(m[[1]], m[[2]], m[[3]], makeUniqueIDs=T) >>> >>> with sp on CRAN this doesn't work; with the version on github it does. >>> >>

Re: [R-sig-Geo] Problems with rbind(list(), makeUniqueIDs=T)

2016-07-22 Thread Bacou, Melanie
> > with sp on CRAN this doesn't work; with the version on github it does. > > An alternative with sp from CRAN is to make the IDs unique by hand: > > spChFIDs(m[[1]]) <- paste0("A", seq(length(m[[1]]))) > spChFIDs(m[[2]]) <- paste0("B", seq(lengt

[R-sig-Geo] Problems with rbind(list(), makeUniqueIDs=T)

2016-07-22 Thread Bacou, Melanie
Hi, I'm getting weird results trying to rbind a list of SpatialPolygonsDataFrames with R 3.2.1 and raster 2.5.8. I believe the code below used to merge all 3 country boundaries, but instead I now get a list with 6 elements (incl. 3 logical TRUE). Am I doing something wrong? Thx, --Mel. >

Re: [R-sig-Geo] putting scalebar and north arrow on google map

2016-07-18 Thread Bacou, Melanie
No self promotion, but in case you're looking for code examples using leaflet plugins (scalebar and minimap) available through `tmap` : http://tools.harvestchoice.org/ar/ (code is linked at the bottom of the page). --Mel. On 7/18/2016 8:36 AM, Tim Appelhans wrote: My suggestion would be the

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

2016-07-15 Thread Bacou, Melanie
Just chiming in, but I don't see any reason for wrapping `readOGR()` and `writeOGR()`. For the sake of code portability and readability, the fact that these 2 functions work for a myriad of vector-based GIS formats is a great thing. You can skip naming parameters to save typing if that's an

Re: [R-sig-Geo] extract value of raster attribute with polygon

2016-07-11 Thread Bacou, Melanie
Also when summarizing classified rasters, it is usual to use the `mode` function (instead of `sum`) since you're typically interested in the dominant class. On 7/11/2016 5:48 PM, Fernando Gimeno wrote: i have a raster with attribute table and i need extract values with a polygon. Help me

Re: [R-sig-Geo] extract value of raster attribute with polygon

2016-07-11 Thread Bacou, Melanie
Simply refer to the documentation for `raster::extract(..., factors=TRUE)`. http://www.inside-r.org/packages/cran/raster/docs/extract --Mel. On 7/11/2016 5:48 PM, Fernando Gimeno wrote: i have a raster with attribute table and i need extract values with a polygon. Help me please.

Re: [R-sig-Geo] Minimum bounding circle from cluster of points (Tina Cormier)

2016-07-09 Thread Bacou, Melanie
Interesting problem, it seems the exact approach is given by Fischer, 2003 and is implemented in a C++ CGAL package (see http://stackoverflow.com/questions/9063453/how-to-compute-the-smallest-bounding-sphere-enclosing-other-bounding-spheres). I haven't found any binding for R, but there's an

Re: [R-sig-Geo] Minimum bounding circle from cluster of points

2016-07-08 Thread Bacou, Melanie
Seems the simplest might be to use the circle that contains your points' bounding box (same center as the bbox and with a diameter equal to its diagonal? Spatial circles may be defined as SpatialPolygonsDataFrame using sampSurf::spCircle().

Re: [R-sig-Geo] Trend significance bfast

2016-07-08 Thread Bacou, Melanie
Note that NDVI trend decomposition is also available in package greenbrown by Matthias Forkel : http://greenbrown.r-forge.r-project.org/trends.php On 7/8/2016 1:58 AM, Bacou, Melanie wrote: Sorry, sent that too fast. `seasonal()` is defined in the bfast package here: https://github.com/cran

Re: [R-sig-Geo] Trend significance bfast

2016-07-07 Thread Bacou, Melanie
Sorry, sent that too fast. `seasonal()` is defined in the bfast package here: https://github.com/cran/bfast/blob/master/R/seasonal.R --Mel. On 7/8/2016 1:51 AM, Bacou, Melanie wrote: Guillaume, See https://www.rforge.net/doc/packages/hydroTSM/seasonalfunction.html for the `zoo:seasonal

Re: [R-sig-Geo] Trend significance bfast

2016-07-07 Thread Bacou, Melanie
Guillaume, See https://www.rforge.net/doc/packages/hydroTSM/seasonalfunction.html for the `zoo:seasonal()` function. In general just look into the package's NAMESPACE to see which libraries are imported. --Mel. On 7/7/2016 5:10 PM, Guillaume Clair wrote: Hi, I'm using the function (and

Re: [R-sig-Geo] projectRaster across the antimeridian

2016-07-01 Thread Bacou, Melanie
Tony, I can confirm this seems like an issue with `projectRaster()`. Using `gdalwarp` instead on the same tile seems to work. # Download geoTIFF BS.terra <- curl::curl_download("https://lance.modaps.eosdis.nasa.gov/imagery/subsets/?subset=BeringSea.2016182.terra.721.2km.tif;,