New answers tagged

0 votes

How to prepare the spatio temporal data sets for Spatio-temporal variogram?

If you are using the spacetime package, you can pass it vectors of space time indicies and a Spatial-class frame (e.g. SpatialPointsDataFrame from sp). Here is an example. library(spacetime) library(...
milo's user avatar
  • 1
0 votes

Spatio Temporal Interpolation with gstat in R

Heyyyy,How are you creating these spatiotemporal data sets. I am facing troubles to make one. I have satelite data for 10 days (say 01-01-2018 to 11-01-2018) at lat long and data values How to create ...
Shibashankar Gouda's user avatar
1 vote
Accepted

Create multiple rasters in PostGIS from a (xyz) table

The Good News: There is an rpostgis package on CRAN which has a pgWriteRast function that can create a PostGIS raster. The Bad News: You only have another 9 days in which you can use it. It works by ...
Spacedman's user avatar
  • 61.5k
1 vote

Colouring wrld_simpl countries with a variable

Its using the integer value behind the factor for the colouring, and then getting the colour from the current palette. Convert the factor to character if you want to use a factor column's levels as ...
Spacedman's user avatar
  • 61.5k
0 votes

How to remove NA value of legend when using R tidyterra?

I prefer using tmap. Note my order of loading libraries, placing of functions, arguments and replacing == with %in%. This can be reproduced even more parsimoniously using other tidyverse functions I ...
Rion Lerm's user avatar
  • 159
1 vote

Tracing a Route on a Map

Check with an online map. The red point top left is Toronto Airport, but all its roads approach from the north, so you haven't included them by using the bounding box to get the OSM data. Expand the ...
Spacedman's user avatar
  • 61.5k
3 votes
Accepted

Mathematical formula to convert lat-lon to Lambert Conformal Conic

So I've figured it out. I had the right formula. To validate that, the projection wkt gives: METHOD["Lambert Conic Conformal (2SP)", ID["EPSG",9802]], Which fits with ...
Bastien's user avatar
  • 607
1 vote
Accepted

Mean and standard error of raster data

That SE seems reasonable. Reversing your calculation tells us that you have > (87/0.02)^2 [1] 18922500 about 19 million pixels. If I create 19 million values from a normal distribution from the ...
Spacedman's user avatar
  • 61.5k
0 votes
Accepted

Pixel level landcover change analysis

Ouch, that double loop is quite unnecessary :) You can use the terra::crosstab function to evaluate class-level change. We will move this analysis to terra so that the depreciation of raster will not ...
Jeffrey Evans's user avatar
0 votes
Accepted

Decide consensus after finding location of unknown point with distances to two known points

Here's how to do it by finding the point that minimises the sum of square differences between the distances in the data and its distance to the points. If the data were perfect, each circle ...
Spacedman's user avatar
  • 61.5k
1 vote
Accepted

MODIS MCD641 quality bits from TIFF file in R

This boils down to "select where bit 0 and bit 1 = 1". Counting up from 0, this happens every fourth integer (ie its true for 3, 7, 11, 15,...). So you can use a modular arithmetic operator, ...
Spacedman's user avatar
  • 61.5k
0 votes

Opening .NC file in R online rather than downloading it

Try OPENDAP url instead if there is any available for your data.
Heerbod's user avatar
1 vote
Accepted

Extent not found on NASA's Black Marble monthly images - How to set it?

Read the data using terra::rast - I'm not sure what sds wins you here, this works: r <- rast("VNP46A3.A2018182.h06v05.001.2021125183820.h5") Define the coordinates to be lat-long WGS84: ...
Spacedman's user avatar
  • 61.5k
0 votes
Accepted

Distance measure that constrains a walk over land and accounts for the shape of the Earth

Here is a Stanford computer science paper from 1992 that describes an algorithm: https://graphics.stanford.edu/courses/cs268-09-winter/notes/handout7.pdf . Unfortunately the coding is left to the ...
til_b's user avatar
  • 4,824
0 votes

R sf package: Error in subsetting geometries - "invalid subscript type 'list'"

st_within() and I think all topological relation functions return a sparse matrix (in a list: see https://r.geocompx.org/spatial-operations.html#topological-relations). You can have multiple points ...
defuneste's user avatar
  • 101
0 votes

Get values from raster file in R

The .ovr file contains "overview" images - lower-resolution versions of the main data file to make mapping at low resolutions quicker, for software that understands it. If you try creating a ...
Spacedman's user avatar
  • 61.5k
1 vote
Accepted

Error using "if" in R: "== : missing value where TRUE/FALSE needed" for spTransform

There's a few problems here: d1 at the error point has an NA (missing) CRS so any attempt to reproject it with spTransform will fail. On my system it fails with a different error message: > d1=...
Spacedman's user avatar
  • 61.5k
0 votes

Double indexing and looping over raster lists in R

This aproach shoud work: re_zero <- list() for(i in 1:length(re)){ r <- re[[i]] r[is.na(r[])] <- 0 re_zero[[i]] <- r }
sermomon's user avatar
  • 1,084
0 votes

Issue with scaling factors for Landsat Collection 2 Level 2 data when calculating NDVI

I don't understand why this problem has been around so long and not fixed at this stage. Not sure what the benefit is to spread the range of digital numbers way beyond the original range to create an ...
Pat Chavez's user avatar
0 votes
Accepted

vis.gam spatial interaction output as a raster grid instead of plot object

You're very close - create a grid of X-Y values and a single value of green (or other covariates) and use predict. Fit the model: fit <- gamm4(age~ s(x,y) +s(green),data=gambia) Make a 150x100 ...
Spacedman's user avatar
  • 61.5k
1 vote

read geojson file which is not in CRS 4326

I don't think the CRS is a problem here. Although the geojson spec says "only use epsg:4326" there is a paragraph in the spec where it grudgingly concedes that if two people agree to use ...
Spacedman's user avatar
  • 61.5k
2 votes

Function to draw lines based on starting point, angle and length

Loads of ways of doing this. Easiest may be to compute the X and Y coords of the start and finish points in R and create a GeoPackage and load that into QGIS instead - use the sf package in R to do ...
Spacedman's user avatar
  • 61.5k

Top 50 recent answers are included