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

2018-02-23 Thread Arnaud Mosnier
t; If this is a base graphics plot using the coordinate system units then you >> can probably get them via some combination of the par() values, or you >> might have set the margins to zero and that gives you the corners from >> par()$usr (I think). >> >> If its grid gra

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

2018-02-07 Thread Arnaud Mosnier
coordinate system units then > you can probably get them via some combination of the par() values, or you > might have set the margins to zero and that gives you the corners from > par()$usr (I think). > > If its grid graphics (like spplot) then uhhh. someone else probably

[R-sig-Geo] Save plot as Geotiff

2018-02-07 Thread Arnaud Mosnier
Hi, Long version: I made a plot (a map) including SpatialPolygons representing the coast of my region of interest, and a SpatialPointsDataframe representing locations of cities, and I want to save this map in GeoTiff format to allow other people to use this map as a georeferenced background withou

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

2015-12-31 Thread Arnaud Mosnier
r line segment, but I'm not sure in what terms you can make > this without ambiguity... > > On Tue, Dec 29, 2015 at 8:05 PM, Arnaud Mosnier > wrote: > > Dear spatial object users, > > > > Is there a way to make a single side buffer (left or right) based on

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

2015-12-29 Thread Arnaud Mosnier
Dear spatial object users, Is there a way to make a single side buffer (left or right) based on SpatialLines? Generally I use the trick consisting in cutting the buffer with the expected width with a really small one, but in this case, it does not works (see below). I think that a single side buf

Re: [R-sig-Geo] Define aliases in shapefiles

2015-04-09 Thread Arnaud Mosnier
common GIS softwares). Have a good day ! Arnaud 2015-04-09 7:50 GMT-04:00 Rainer M Krug : > Barry Rowlingson writes: > > > On Wed, Apr 8, 2015 at 7:53 PM, Arnaud Mosnier > wrote: > >> Dear useRs, > >> > >> I am searching for a way to break the 10 cha

Re: [R-sig-Geo] Define aliases in shapefiles

2015-04-09 Thread Arnaud Mosnier
gt; > On Wed, Apr 8, 2015 at 7:53 PM, Arnaud Mosnier > wrote: > >> Dear useRs, > >> > >> I am searching for a way to break the 10 character limit of the field > names > >> in shapefiles created using for example the writeOGR function from the > >

[R-sig-Geo] Define aliases in shapefiles

2015-04-08 Thread Arnaud Mosnier
Dear useRs, I am searching for a way to break the 10 character limit of the field names in shapefiles created using for example the writeOGR function from the rgdal package. On way could be to define aliases for field names, but I am not aware of a function allowing me to do that. Any suggestion

Re: [R-sig-Geo] Extracting raster weighted mean without NAs

2014-09-24 Thread Arnaud Mosnier
45 > > Regards, > Pascal > > On Wed, Sep 24, 2014 at 10:59 PM, Arnaud Mosnier > wrote: > > Hi, > > > > I need to extract the mean value of raster values into several > > spatialPolygons. > > I use the extract function from the raster package with the

[R-sig-Geo] Extracting raster weighted mean without NAs

2014-09-24 Thread Arnaud Mosnier
Hi, I need to extract the mean value of raster values into several spatialPolygons. I use the extract function from the raster package with the weight option in order to take into account the area of each raster cell with data included into each polygon. However, I want to make the calculation eve

Re: [R-sig-Geo] Specifying Albers projection for the contiguous US

2014-05-01 Thread Arnaud Mosnier
You can probably use CRS("+proj=longlat +datum=WGS84") --- >Hello, >I?m trying to use the map function from package maps to draw the contiguous United States with the projection, "+proj=aea >+lat_1=29.5 +lat_2=45.5 +lat_0=39.8

Re: [R-sig-Geo] Defining CRS when loading a raster doesn't seems to work anymore

2013-11-19 Thread Arnaud Mosnier
> > bit obscure until you understand that the character method (for a > > file) does not allow you to pass in crs at that point, it's only > > defined for the signatures "missing", "Extent", "matrix" and > > "big.matrix". > &g

Re: [R-sig-Geo] Defining CRS when loading a raster doesn't seems to work anymore

2013-11-15 Thread Arnaud Mosnier
; r <- raster() > projection(r) > projection(r) <- "+proj=lcc +lat_1=48 +lat_2=33 +lon_0=-100 +ellps=WGS84" > projection() > > > Might help, > > Best, > Jan > > > On 15/11/13 17:52, "Arnaud Mosnier" wrote: > > >Hi all, > >

[R-sig-Geo] Defining CRS when loading a raster doesn't seems to work anymore

2013-11-15 Thread Arnaud Mosnier
Hi all, I re-run a script written some times ago containing a line like the following test <- raster("myraster.tif", crs = "+proj=longlat +ellps=WGS84") The file is loaded correctly, but the crs was not attributed. >proj4string(test) gives me [1] "NA" When looking at the help file, nothing

Re: [R-sig-Geo] Fit a sine curve to raster stack

2013-11-08 Thread Arnaud Mosnier
/7 Sofea Wright > Thanks a lot Arnaud Mosnier! > > The code is running however, the final output is strange. The minimum > values and maximum values is NA. I would expect it to give me the > slope (coeefficients[2] is the slope). I just could not figure out > where I went wrong. &

Re: [R-sig-Geo] Fit a sine curve to raster stack

2013-11-07 Thread Arnaud Mosnier
Just change the s for a x in fun1 <- function(x) { if (is.na(x[1])) { NA } else { xcost<-cos(2*pi*time/12) xsine<-sin(2*pi*time/12) m = lm(s~xcost+xsine) m$coefficients[2] } } this should work ! fun1 <- function(x) { if (is.na(x[1])) { NA } else { xcost<-cos(2*pi*time/12) xsine<-sin(2*pi*time/12

Re: [R-sig-Geo] Area calculation error ?

2013-06-26 Thread Arnaud Mosnier
Sorry ... my mistake ... the rectangle is slightly rotated ... here is the difference. Arnaud 2013/6/26 Arnaud Mosnier > Hi, > > Maybe I made an error somewhere, but I can't find where ! > There is differences when I calculated the area of a rectangular polygon > and the

[R-sig-Geo] Area calculation error ?

2013-06-26 Thread Arnaud Mosnier
Hi, Maybe I made an error somewhere, but I can't find where ! There is differences when I calculated the area of a rectangular polygon and the value calculated by the function Polygon. Sorry for the large precision numbers, but I tested if it was due to a rounding error. Hope you can enlighten m

Re: [R-sig-Geo] remove points less than certain distance

2013-04-29 Thread Arnaud Mosnier
This should do what you want. Be careful, in the order of the points in your SpatialPointsDataFrame is important ! d<-spDists(xy) <= 0.2 d[upper.tri(d, diag=T)] <-NA select<-xy[-which(apply(d, 1,function(x) any(x == TRUE))),] plot(select) Arnaud > # I have a SpatialPointsDataFrame that contains

Re: [R-sig-Geo] Raster and layout

2013-01-29 Thread Arnaud Mosnier
mat=layout.matrix) layout.show(4) image(b[[1]]) image(b[[1]]) image(b[[1]]) image(b[[1]]) image(b[[1]]) Arnaud 2013/1/29 Arnaud Mosnier > Hi all, > > Here is a problem that seems to be rather old (see the ref at the end of > the message). > > When I use the layout function to

[R-sig-Geo] Raster and layout

2013-01-29 Thread Arnaud Mosnier
Hi all, Here is a problem that seems to be rather old (see the ref at the end of the message). When I use the layout function to split the device into unequal parts then plot a raster object, the layout is completely modified. Here is a code to reproduce the problem. library (raster) b<- brick

Re: [R-sig-Geo] spatial regression model

2012-11-01 Thread Arnaud Mosnier
Paolo, Using GLS seems a good approach for what you want to do. However, as its names indicates GLS models does not use the OLS approach, so you can't use the "classic" R square interpretation. I would follow these steps (but if I am wrong please feel free to correct me !!). 1) Run your model in

Re: [R-sig-Geo] read MODIS image in HDF format

2012-04-11 Thread Arnaud Mosnier
If I remember correctly, MODIS images are in HDF4 format and if you are in a windows environment gdal is not compiled with the hdf4 driver. As already suggested, you can use FWTools to convert them in geotiff (for example). You can call gdal_translate implemented in it (this version of gdal is comp

Re: [R-sig-Geo] select cells in a raster and change the values to 1

2012-03-19 Thread Arnaud Mosnier
With your example, r <- raster(ncol=3, nrow=3) r[] <- 1:ncell(r) #a vector of cells I want to select vals<-c(2,4,6) plot(r) values(r) <- ifelse(values(r) %in% vals, 1, NA) dev.new() plot(r) Arnaud [[alternative HTML version deleted]] ___ R-sig

Re: [R-sig-Geo] select cells in a raster and change the values to 1

2012-03-19 Thread Arnaud Mosnier
See example below. rast<- raster(nrows=10, ncols=10) rast[1:20] <- 3 rast[21:25] <- 9 rast[26:40] <- 2 rast[40:50] <- 7 rast[51:100] <- 1 plot(rast) values(rast) <- ifelse(values(rast) %in% c(9,7), 1, NA) # just replace c(9,7) by your vector dev.new() plot(rast) Arnaud [[alternative HTML

Re: [R-sig-Geo] Convert netcdf file to a raster ...

2012-03-14 Thread Arnaud Mosnier
, 2012 at 12:10 PM, Barry Rowlingson < > b.rowling...@lancaster.ac.uk> wrote: > >> On Wed, Mar 14, 2012 at 4:14 PM, Arnaud Mosnier >> wrote: >> > Hi all, >> > >> > I am trying to open a netCDF file ( >> > >> ftp://globcolour_data:fg

Re: [R-sig-Geo] Convert netcdf file to a raster ...

2012-03-14 Thread Arnaud Mosnier
It would be nice to have a good "sparse raster" format; but unfortunately > this one does not look like a generic implementation. > > Robert > > > On Wed, Mar 14, 2012 at 12:10 PM, Barry Rowlingson < > b.rowling...@lancaster.ac.uk> wrote: > >> On Wed, Mar

[R-sig-Geo] Convert netcdf file to a raster ...

2012-03-14 Thread Arnaud Mosnier
Hi all, I am trying to open a netCDF file ( ftp://globcolour_data:fgh...@ftp.acri.fr/GLOB_4KM/RAN/CHL1/MERGED/GSM/2007/DAILY/L3b_20070615__GLOB_4_GSM-MERMODSWF_CHL1_DAY_00.nc.gz ). However, when I use the raster package to load it as a raster ... library(raster) test<-raster("D:\\temp\\testAQUAT

Re: [R-sig-Geo] Removing spatial autocorrelation - Memory limits

2011-12-12 Thread Arnaud Mosnier
Chris, If you only want to investigate if certain "area" (clusters of cells) have high numbers of fish than others. You can try to use a cluster analysis. See the packages "cluster" or "FactoMineR" Arnaud - Date: Mon, 12 Dec 201

[R-sig-Geo] Sampling point density increasing with distance from a polygon or a line

2011-10-25 Thread Arnaud Mosnier
Dear Geo Users, I am trying to create "random" points which density decrease with the distance from a polygon or a line. Is there an function in R that can allow me to do that ? Arnaud [[alternative HTML version deleted]] ___ R-sig-Geo mailing

[R-sig-Geo] Convert raster to polygon

2011-10-13 Thread Arnaud Mosnier
Dear all, In searching a solution from the internet, I found someone who had the same problem as me but ... who had no answers. I hope I will have better chance! :-) Here is her explanation: http://r-sig-geo.2731867.n2.nabble.com/Converting-raster-to-polygons-with-just-one-polygon-for-cells-with

Re: [R-sig-Geo] Logarithmic legend

2011-10-06 Thread Arnaud Mosnier
Paul, I never used ggplot2 before. I have to look seriously at the possibilities of this package. Robert, I will wait for the next version of the raster package (Is the updated version available on R forge ?). Thanks a lot to both of you ! Arnaud [[alternative HTML version deleted]] __

[R-sig-Geo] Logarithmic legend

2011-10-05 Thread Arnaud Mosnier
Dear Geo Users, Please, can someone explain me how to plot a raster using a logarithmic scale and obtaining the legend with this scale ? Thanks for any help, Arnaud [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-p

[R-sig-Geo] Jenks classification for raster representation

2011-09-16 Thread Arnaud Mosnier
Dear list, In order to allow others benefiting from my errors, see below a presentation of a problem and it's solution by Roger Bivand (Thanks !). ## I want to use natural breaks (jenks) method to find class intervals into raster's values in order to plot it w

[R-sig-Geo] Split function ?

2011-09-12 Thread Arnaud Mosnier
Dear list, Is there a function in R that allow to split a SpatialLinesDataFrame into segments of a defined length ? Thanks, Arnaud [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@r-project.org https://stat.ethz.ch/ma

Re: [R-sig-Geo] Read HDF files

2011-09-06 Thread Arnaud Mosnier
Thanks for making that crystal clear. For the moment, I will probably stick to FWtools to make my conversions, but I hope I will have time to learn how to build gdal from source including the drivers I need. Thanks again, Arnaud 2011/9/4 Roger Bivand > On Sat, 3 Sep 2011, Arnaud Mosnier wr

Re: [R-sig-Geo] Read HDF files

2011-09-03 Thread Arnaud Mosnier
Hi Jan, Thanks for you answer. I tried your script but unfortunatly it does not work for my case. If someone want to make some test with the kind of image I want to use, just try this script to download and uncompress it. TestFolder <- choose.dir() download.file(" http://oceandata.sci.gsfc.nasa.

Re: [R-sig-Geo] Read HDF files

2011-09-02 Thread Arnaud Mosnier
. So my question is now ... can someone give me a step by step instruction that I can use to build a GDAL version including the support for HDF4 format (as it is the case in the version compiled with FWtools) ? Thanks, Arnaud 2011/9/2 Paul Hiemstra > On 09/01/2011 05:20 PM, Arnaud Mosn

[R-sig-Geo] Read HDF files

2011-09-01 Thread Arnaud Mosnier
Hi Geo UseRs, I am searching a way to read and manage HDF files in R (like files provided by the ocean color web site, http://oceancolor.gsfc.nasa.gov/). Thanks Arnaud [[alternative HTML version deleted]] ___ R-sig-Geo mailing list R-sig-Geo@

Re: [R-sig-Geo] GLS model

2011-07-08 Thread Arnaud Mosnier
Dear Yiching, For now, I just use the square of the correlation between the observed and predicted values​​. But if someone has another solution, I am also very interested in suggestions! Arnaud [[alternative HTML version deleted]] ___ R-s

[R-sig-Geo] GLS models and variance explained

2011-06-22 Thread Arnaud Mosnier
Dear list, Inspecting residuals of my linear models, I detected spatial autocorrelation. In order to take this into account, I decided to use the GLS method with the correlation = corGaus ( ~ X + Y). Then, I can sort my GLS models based on their AIC. But ... how to know the proportion of the vari

Re: [R-sig-Geo] Spatial autocorrelation in GLM/GAM/CART binomial family

2011-04-29 Thread Arnaud Mosnier
Federico, I recommend reading the following paper : Methods to account for spatial autocorrelation in the analysis of species distributional data: a review Carsten F. Dormann, Jana M. McPherson, Miguel B. Araújo, Roger Bivand, Janine Bolliger, Gudrun Carl, Richard G. Davies, Alexandre Hirzel, Wal

[R-sig-Geo] Need help understanding the spatial correlation structure applied in lme

2011-02-21 Thread Arnaud Mosnier
Dear Users, I apologize to resubmit this question to your brains, but I need to understand some of my results to be sure that I did not make errors setting my analysis. So, even (and particularly) if the answer is "You are totally wrong", please let me know ! >From previous analysis (semi-variogr

[R-sig-Geo] Bug in the function Variogram (package nlme) ?

2011-02-18 Thread Arnaud Mosnier
Dears UseRs, In Zuur's book (Mixed effects models and extensions in ecology with R), p 167, it is mentionned that the Variogram function (package nlme) scale the sill to 1. Here is the plot of the semi-variogram given by the Variogram function on my "lme" object. (http://imm.io/3OLe) Note that the

[R-sig-Geo] Variogram (nlme) of a lme object - corSpatial element question

2011-02-18 Thread Arnaud Mosnier
Dear Users, >From previous analysis (semi-variograms using package gstat), I found spatial autocorrelation in my dataset. The best fitted model to this spatial correlation structure is the Gaussian model (Spherical, Exponential, Linear tested and comparison done by Sum of Square errors). So I used

[R-sig-Geo] lme and spatial autocorrelation

2011-02-08 Thread Arnaud Mosnier
Dear Mixed-Modelers, Sorry to re-post this message. I am trying to fit linear models using lme and considering the spatial autocorrelation structure of my data. I know that the correlation has a half-normal shape, so I use the function corGaus. Observations are coming from several surveys, done

[R-sig-Geo] Spatial autocorrelation structure

2011-02-03 Thread Arnaud Mosnier
Dear Geo-UseRs, I am trying to fit a linear model in lme considering the spatial autocorrelation structure of my data. I know that the correlation has a half-normal shape, so I use the function corGaus. Observations are coming from several surveys, done at various dates (sometimes several surveys

[R-sig-Geo] Cross-Validation package

2010-12-14 Thread Arnaud Mosnier
Sure, It would be much appreciated !! Arnaud -- Would it be worthwile to the R-sig-geo community to expand this code into a crossvalidate package? This package could provide an easy means of crossvalidating

[R-sig-Geo] Spatial interpolation possibilities

2010-12-03 Thread Arnaud Mosnier
Dear GeoUseRs, >From the large number of methods that can be used to spatially interpolate data, we tried several of them (Inverse Distance Weighted, Natural Neighbour, Spline, Kriging, Co-Kriging) on our dataset. We used ArcGIS to apply the first three and R for kriging and test possibilities of