Extract values at specific lat long list from Netcdf file

Hi experts,
I have a netcdf file (https://zenodo.org/record/1198817/files/da_hydro_AprMar_r.1-2000_d.05-Jan-2018.nc?download=1). I want to extract values from this file at specific locations, using a list of lat long. Please, can you help me :slight_smile:

The code I'm trying is here--

rm(list=ls(all=TRUE))
library(terra)
library(raster)


setwd("D:/work/data_files/nc_data")
ncin <- rast("da_hydro_AprMar_r.1-2000_d.05-Jan-2018.nc", subds="tas_mn", 
             drivers = "NETCDF")
#> Error in rast("da_hydro_AprMar_r.1-2000_d.05-Jan-2018.nc", subds = "tas_mn", : could not find function "rast"
print(ncin)
#> Error in print(ncin): object 'ncin' not found

names(ncin)
#> Error in eval(expr, envir, enclos): object 'ncin' not found

# # Subset the proxy points
points <-read.csv("C:/Users/data/Desktop/points.csv")
x<-points$Longitude
y<-points$Latitude

xy <- cbind(data.frame(x,y))

extr_dt <- raster::extract(ncin, xy, xy=TRUE)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'extract': object 'ncin' not found

spei_df <- as.data.frame(extr_dt, xy = TRUE)
#> Error in as.data.frame(extr_dt, xy = TRUE): object 'extr_dt' not found

Created on 2022-12-19 with reprex v2.0.2

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.