Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get coordinates of netcdf in python

# To extract coordinates values from a datatable using xarray

import xarray as xr
import numpy as np
import pandas as pd

# This sectin creates a dummy data
years=range(1982,1986)
time = pd.date_range('14/1/' + str(years_arr[0]) + ' 12:00:00', periods=len(years_arr), freq=pd.DateOffset(years=1))
lon = range(20,24)
lat = range(10,14)
arr1 = xr.DataArray(data, coords=[time, lat, lon], dims=['time', 'latitude', 'longitude'])

# This section performs the extraction
# extract coordinate value of the lon
arr1.coords['lon'] 			# gives you longitude as a xarray.DataArray, and
arr1.coords['lon'].values 	# gives you the values as a numpy array.

# extract all coordinates (time, lat, lon) values
time, lat, lon = arr1.indexes.values()
Comment

PREVIOUS NEXT
Code Example
Python :: make parameter optional python 
Python :: turtle graphics documentation 
Python :: pop list python 
Python :: digital differential analyzer 
Python :: how to make a comment in python 
Python :: print without newline 
Python :: how to read .xlsx file in python 
Python :: get xlim python 
Python :: how to count number of records in json 
Python :: how to read json from python 
Python :: how to remove an element from a list in python 
Python :: python get total gpu memory 
Python :: push in python 
Python :: python lambda key sort 
Python :: python panda count excel sheet 
Python :: color plt 
Python :: pytube python 
Python :: pandas resample friday 
Python :: pandas pivot table 
Python :: python how to add a string to a list in the middle 
Python :: float64 python 
Python :: code 
Python :: if else in python 
Python :: dict in dict in python 
Python :: py one line function 
Python :: python ceiling division 
Python :: web scraping using python code 
Python :: stack details in python 
Python :: python qr decomposition 
Python :: django class based views 
ADD CONTENT
Topic
Content
Source link
Name
9+5 =