I have a netcdf file (global domain) which I do not know its projection information, and I want to extract the data (with lon and lat) based on the shapefile.
The objective is to find data for the domain represented by the shapefile ( the original netcdf contains global data). Besides, the final data format should be a data frame, which contains lon, lat, and data. I assume that the extract
and mask
function will be useful.
The netcdf and shapefile can be found at https://www.dropbox.com/s/ju96eitzzd0xxg8/precip.2000.nc?dl=0 and https://www.dropbox.com/s/8wfgf8207dbh79r/gpr_000b11a_e.zip?dl=0. Thanks for any help.
library(rgdal)
library(ncdf4)
library(raster)
shp = readOGR("gpr_000b11a_e.shp")
pre1 = nc_open("precip.2000.nc")
pre1
File precip.2000.nc (NC_FORMAT_NETCDF4_CLASSIC):
1 variables (excluding dimension variables):
float precip[lon,lat,time]
missing_value: -9.96920996838687e+36
var_desc: Precipitation
level_desc: Surface
statistic: Total
parent_stat: Other
long_name: Daily total of precipitation
cell_methods: time: sum
avg_period: 0000-00-01 00:00:00
actual_range: 0
actual_range: 482.555358886719
units: mm
valid_range: 0
valid_range: 1000
dataset: CPC Global Precipitation
3 dimensions:
lat Size:360
actual_range: 89.75
actual_range: -89.75
long_name: Latitude
units: degrees_north
axis: Y
standard_name: latitude
coordinate_defines: center
lon Size:720
long_name: Longitude
units: degrees_east
axis: X
standard_name: longitude
actual_range: 0.25
actual_range: 359.75
coordinate_defines: center
time Size:366 *** is unlimited ***
long_name: Time
axis: T
standard_name: time
coordinate_defines: start
actual_range: 876576
actual_range: 885336
delta_t: 0000-00-01 00:00:00
avg_period: 0000-00-01 00:00:00
units: hours since 1900-01-01 00:00:00
7 global attributes:
Conventions: CF-1.0
version: V1.0
history: created 9/2016 by CAS NOAA/ESRL PSD
title: CPC GLOBAL PRCP V1.0
References: https://www.esrl.noaa.gov/psd/data/gridded/data.cpc.globalprecip.html
dataset_title: CPC GLOBAL PRCP V1.0
Source: ftp://ftp.cpc.ncep.noaa.gov/precip/CPC_UNI_PRCP/
As we can see, there is no information about the projection or crs for the netcdf file.