Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extract_metrics removes raster layer ID if present #27

Closed
ttrotto opened this issue Feb 10, 2023 · 1 comment
Closed

extract_metrics removes raster layer ID if present #27

ttrotto opened this issue Feb 10, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@ttrotto
Copy link

ttrotto commented Feb 10, 2023

When running extract_metrics on a SpatRaster with an ID layer, the function removes it.

Source code here

Example:

# get template raster
r <- system.file("extdata", "mraster.tif", package = "sgsR")
mr <- terra::rast(r)

# import existing polygons
e <- system.file("extdata", "existing.shp", package = "sgsR")
e <- sf::st_read(e)

# rename one layer to 'ID'
names(mr) <- c('ID', 'pzabove2', 'zsd')

# extract metrics
extract_metrics(mr, e)

# Simple feature collection with 200 features and 3 fields
# Geometry type: POINT
# Dimension:     XY
# Bounding box:  xmin: 431110 ymin: 5337710 xmax: 438530 ymax: 5343230
# Projected CRS: UTM_Zone_17_Northern_Hemisphere
# First 10 features:
#   pzabove2  zsd FID               geometry
# 1      23.4 0.74   0 POINT (433650 5340870)
# 2       2.6 1.47   1 POINT (434430 5339050)
# 3      60.4 1.73   2 POINT (433830 5341130)
# 4      22.7 0.95   3 POINT (434070 5341110)
# 5      62.2 1.07   4 POINT (432950 5343230)
# 6      55.4 2.31   5 POINT (432990 5342450)
# 7      65.7 2.60   6 POINT (432050 5342890)
# 8      52.5 2.84   7 POINT (438250 5339310)
# 9      63.7 2.85   8 POINT (434970 5342590)
# 10     15.0 0.41   9 POINT (437770 5339150)
@tgoodbody tgoodbody self-assigned this Feb 10, 2023
@tgoodbody tgoodbody added the bug Something isn't working label Feb 10, 2023
@tgoodbody
Copy link
Owner

fixed in dev branch

tgoodbody added a commit that referenced this issue Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants