Comments (7)
@mitchellmanware In process_nlcd
, I use terra::metags
to record year. Since GMTED and SEDAC data were produced in a single year, year could be added in the similar way with year value hard-coded. If we expect future updates in these datasets, it would be good to add year
argument in process_*
functions.
Line 680 in 0374128
from amadeus.
- GMTED
- SEDAC groads
- SEDAC population
- Koppen-Geiger
- Ecoregions
from amadeus.
@sigmafelix
When reviewing the process_
and calc_
functions, I have noticed that some of the calc_
functions you created accept only SpatVector
or sf
objects as locations.
Example is from calc_ecoregions
calc_ecoregion <-
function(
from = NULL,
locs,
locs_id = "site_id",
...
) {
if (!methods::is(locs, "SpatVector")) {
locs <- terra::vect(locs)
}
Is there a reason you do not use the process_conformity
function to accept SpatVector
, sf
, and data.frame
alike?
Could be:
calc_ecoregion <-
function(
from = NULL,
locs,
locs_id = "site_id",
...
) {
if (!methods::is(locs, "SpatVector")) {
locs <- process_conformity(locs = locs)
}
to accept all three classes.
from amadeus.
See commit 062f448.
Year/range metadata tag has been added for GMTED, groads, population, and Koppen Geiger process_*
functions and a $time
column for their calc_
functinos. For GMTED and SEDAC population, single year is returned (always 2010 for GMTED and variable for population depending on user-selected year).
For SEDAC groads, Koppen Geiger, and ecoregions functions, I have added the year range coverage as indicated by the datasets' descriptions. For example, SEDAC groads data was collected covering the period of 1980 to 2010, and is therefore added as a metadata tag and covariate column.
> ### sedac groads
> g <- process_sedac_groads(
+ path = "tests/testdata/groads_test.shp"
+ )
> calc_sedac_groads(
+ g,
+ l,
+ "id"
+ )
id time GRD_TOTAL_0_01000 GRD_DENKM_0_01000
1 3799900018810101 1980 - 2010 1.762476 0.5633273
> ### koppen geiger
> k <- process_koppen_geiger(
+ path = "tests/testdata/koppen_subset.tif"
+ )
> terra::metags(k)
year
"1980 - 2016"
> calc_koppen_geiger(
+ k,
+ l,
+ "id"
+ )
id time DUM_CLRGA_0_00000 DUM_CLRGB_0_00000 DUM_CLRGC_0_00000 DUM_CLRGD_0_00000 DUM_CLRGE_0_00000
1 3799900018810101 1980 - 2016 0 0 1 0 0
> ### ecoregions
> e <- process_ecoregion(
+ path = "tests/testdata/eco_l3_clip.gpkg"
+ )
> site_faux <-
+ data.frame(
+ site_id = "37999109988101",
+ lon = -77.576,
+ lat = 39.40,
+ date = as.Date("2022-01-01")
+ )
> site_faux <-
+ terra::vect(
+ site_faux,
+ geom = c("lon", "lat"),
+ keepgeom = TRUE,
+ crs = "EPSG:4326")
> site_faux <- terra::project(site_faux, "EPSG:5070")
> calc_ecoregion(
+ e,
+ site_faux,
+ "site_id"
+ )
site_id time DUM_E2083_0_00000 DUM_E3064_0_00000
1 37999109988101 1997 - 2024 1 1
>
Although this does not conform to the normal values in the $time
column, at least it is consistent with the original dataset.
HUC and OpenLandMap are the only datasets that do not include some sort of time information.
from amadeus.
@mitchellmanware I think time
field is supposed to be working as one of keys. In the demonstration above, the time
field looks like a field with description on the time of representation in the source dataset. An advantage of using time
field as a key is that users will be able to join multiple calc_*
results with common keys. Could we move the source data description into a separate field with a name, for example, description
?
from amadeus.
@sigmafelix
Yes, that makes sense. I will update.
from amadeus.
Update
> e <- process_ecoregion(
+ path = "tests/testdata/eco_l3_clip.gpkg"
+ )
> site_faux <-
+ data.frame(
+ id = "1",
+ lon = -77.576,
+ lat = 39.40,
+ date = as.Date("2022-01-01")
+ )
> site_faux <- terra::vect(site_faux, crs = "EPSG:4326")
> site_proj <- terra::project(site_faux, terra::crs(e))
> calc_ecoregion(
+ e,
+ site_proj,
+ "id"
+ )
id description DUM_E2083_0_00000 DUM_E3064_0_00000
1 1 1997 - 2024 1 1
from amadeus.
Related Issues (20)
- Return `SpatVector` or `sf` object from `calc_covariates` HOT 3
- Add imperviousness to amadeus catalog HOT 1
- Add tree canopy cover to amadeus catalog
- Add forest canopy height to amadeus catalog
- Add building footprint to amadeus catalog HOT 3
- Add building height to amadeus catalog HOT 2
- Add local climate zone to amadeus catalog HOT 1
- Cropping extent for `process_*` HOT 3
- Single `download_narr` function HOT 1
- `download_*` optional parameters HOT 4
- Update vignettes HOT 1
- `download_narr` soil variables HOT 1
- update option names for "mode" variable in process_aqs.R HOT 1
- pkgdown code not copyable HOT 5
- `process_hms` refactoring: treat all levels at once HOT 3
- `download_*()` references HOT 3
- `download_narr` broken HOT 1
- Temporal dimension in calc_<> functions HOT 9
- [IDEA] Calc terrain covariates
- `download_*()` on Windows OS HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amadeus.