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 :: pairwise function python 
Python :: beautifulsoup getting data from a website 
Python :: how to handle missing values in dataset 
Python :: dda line drawing algorithm 
Python :: python . 
Python :: how to take input of something in python 
Python :: python colored text into terminal 
Python :: get key from dict python 
Python :: how to generate random number in python 
Python :: django bulk update 
Python :: how to make curl request python 
Python :: f readlines python not working 
Python :: python programm zu exe 
Python :: python capitalize the entire string 
Python :: ajouter element liste python 
Python :: django form example 
Python :: python list all columns in dataframe 
Python :: Looping and counting in python 
Python :: split string python 
Python :: python how to extract a string from another string 
Python :: #pip install commands 
Python :: has no attribute python 
Python :: condition in python 
Python :: pandas fillna with none 
Python :: python single line function 
Python :: string list to list 
Python :: how to print in python 
Python :: stack program in python3 
Python :: django sessions for beginners 
Python :: python write subprocess stdout stderr to file 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =