Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

xarray get number of lat lon

# 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 :: run all python files in a directory in windows 
Python :: run all python files in a directory in bash 
Python :: check datatype python 
Python :: pandas insert a list into cell 
Python :: install scrapy on pycharm 
Python :: array sort python 
Python :: request download file 
Python :: get drive path python 
Python :: binary tree in python 
Python :: python merge dict 
Python :: python curl 
Python :: expand alphabets in python 
Python :: how to remove role discord bot python 
Python :: python tkinter button image 
Python :: how to numbered jupyter notebook 
Python :: urllib.error.HTTPError: HTTP Error 404: Not Found 
Python :: pytorch squeeze 
Python :: Drop multiple columns with their index 
Python :: gyp err! stack error: command failed: c:python39python.exe -c import sys; print "%s.%s.%s" % sys.version_info[:3]; 
Python :: sort values within groups pandas dataframe 
Python :: simple seaborn heatmap 
Python :: python char at 
Python :: python conditions 
Python :: python combinations 
Python :: dataframe multiindex 
Python :: python treemap example 
Python :: why are my static files not loading in django 
Python :: stack in python 
Python :: progress bar in python 
Python :: python queue not empty 
ADD CONTENT
Topic
Content
Source link
Name
3+4 =