Skip to main content
Search type Search syntax
Tags [tag]
Exact "words here"
Author user:1234
user:me (yours)
Score score:3 (3+)
score:0 (none)
Answers answers:3 (3+)
answers:0 (none)
isaccepted:yes
hasaccepted:no
inquestion:1234
Views views:250
Code code:"if (foo != bar)"
Sections title:apples
body:"apples oranges"
URL url:"*.example.com"
Saves in:saves
Status closed:yes
duplicate:no
migrated:no
wiki:no
Types is:question
is:answer
Exclude -[tag]
-apples
For more details on advanced search visit our help page
Results tagged with
Search options not deleted user 84287

Statistical computing language and software environment.

0 votes
1 answer
194 views

Sum two raster stack together ignoring NAs

I have 2 rasters with multiple layers that I want to sum together. Both raster have the same number of layers, and I want to sum all the layer from one raster to their respective layers in the second …
1 vote

Can extracting raster values work in polygons' CRS without raster resampling?

The answer to your first question is yes, changing the projection from EPSG:4326 to EPSG:23031 will resample your values. It's easy to imagine knowing that 4326 creates pixels with different size and …
Bastien's user avatar
  • 649
1 vote
1 answer
810 views

Mathematical formula to convert lat-lon to Lambert Conformal Conic

I've found this link that refers to this manual which I tried to reproduce in R, with no success. … Finally: E = EF + r * sin(theta) N = NF + rF - r * cos(theta) Running this produce: cbind(E, N) E N [1,] 7673386 1349263 [2,] 7325110 1025063 [3,] 5617116 1594762 [4,] 3999380 2227177 …
3 votes
Accepted

Mathematical formula to convert lat-lon to Lambert Conformal Conic

tan(pi/4 - latF/2)/((1 - e * sin(latF))/(1 + e * sin(latF)))^(e/2) t = tan(pi/4 - lat/2)/((1 - e * sin(lat))/(1 + e * sin(lat)))^(e/2) n = (log(m1) - log(m2))/(log(t1) - log(t2)) FF = m1/(n * t1^n) r … = a * FF * t^n # for rF and r, where rF is the radius of the parallel of latitude of the false origin. rF = a * FF * tF^n theta = n * (lon - lon0) E = EF + r * sin(theta) N = NF + rF - r * …
Bastien's user avatar
  • 649
1 vote
1 answer
848 views

Do a "3D" extract from a raster stack at specific space and time location in a sf spatial ob...

That maybe it was already coded in the raster, sf, stars or another package in R. … The idea here is really to do a space-time uneven extract between a raster brick and a spatial point object in R. …
4 votes
1 answer
2k views

st_intersection from sf package do not clip the territory correctly

I want to clip a polygon shapefile using sf::st_intersection, however the territory is not cut straight. Here is a RE. I use a Canadian province shapefile that can be downloaded easily: library(sf) l …
1 vote
Accepted

Reading NARR reanalysis data with raster package makes R crash

As @mdsumner specified in its comment, you need to specify the mode of download as binary like: download.file("ftp://ftp.cdc.noaa.gov/Datasets/NARR/Dailies/monolevel/csnow.2019.nc", the_NetCDF, mode …
Bastien's user avatar
  • 649
1 vote
1 answer
258 views

Reading NARR reanalysis data with raster package makes R crash

I'm trying to analyse data from NARR (NCEP North American Regional Reanalysis) and every time I try my R session crash. … here is my session info if it can help: R version 3.6.2 (2019-12-12) Platform: x86_64-w64-mingw32/x64 (64-bit) Running under: Windows 10 x64 (build 18362) Matrix products: default locale: [1] LC_COLLATE …
1 vote

Define catchment boundaries with GIS using R

To complete @Marco's answer, watershed can be done in GRASS through RQGIS3 or done in RSAGA. Of course, you need QGIS, GRASS and SAGA installed on your computer. Here is an example. The DEM comes f …
Bastien's user avatar
  • 649
2 votes
1 answer
2k views

Clustering spatially connected polygons so all clusters have approximately the same size

I'm open for a solution is R, QGIS, SAGA or GRASS. …
2 votes

Clustering spatially connected polygons so all clusters have approximately the same size

I finally found a way, I scripted my own clustering function in R which works relatively great. The idea is to start from the neighbor list and iteratively make groups. … size reach Remove all polygons grouped before from the neighbors list repeat 1 and 2 until no more polygons are availables Fuse the small leftover groups to majors groups I coded this algorithm in R
Bastien's user avatar
  • 649
1 vote
1 answer
1k views

Using datatype option from writeRaster with ascii files

I'm trying to use R writeRaster fonction, however it is not working: Reproducible example: library(raster) rr <- raster(matrix(sample(1:100, 100),10,10), xmn=0, xmx=10, ymn=0, ymx=10) writeRaster(rr …
1 vote

Create a shapefile from dataframe in R, keeping attribute table

When you use the function SpatialPointsDataFrame(), the "data.frame" argument is where you get all the data you want in your shape. Now, you're putting only an ID. Try: LLcoor.df2=SpatialPointsD …
Bastien's user avatar
  • 649