Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

get coordinates in xarray

# 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 :: netcdf in python 
Python :: tkinter frames and grids 
Python :: python 3 tkinter treeview example 
Python :: python use variable name as variable 
Python :: split paragraphs in python 
Python :: read a function of excel in python 
Python :: xml depth python 
Python :: pandas pivot to sparse 
Python :: tables in python 
Python :: django channel 
Python :: read csv python 
Python :: labelimg yolo save format 
Python :: how to remove role from people with a reaction discord bot python 
Python :: python math functions 
Python :: how to use django-rest-framework-datatables 
Python :: how to use if else in python 
Python :: calculate quantiles python 
Python :: multi threading in python for 2 different functions with return 
Python :: torch print full tensor 
Python :: getting multiple of 5 python 
Python :: simple heatmap 
Python :: function wrapper with variable number of arguments python 
Python :: keyboard python 
Python :: del list python 
Python :: how to code a trading bot in python 
Python :: Kivy Python ListView Scrollview with Toggle on off 
Python :: align a text python 
Python :: Flatten List in Python Using NumPy flat 
Python :: python module path 
Python :: exit code python 
ADD CONTENT
Topic
Content
Source link
Name
6+9 =