id,node_id,number,title,user,state,locked,assignee,milestone,comments,created_at,updated_at,closed_at,author_association,active_lock_reason,draft,pull_request,body,reactions,performed_via_github_app,state_reason,repo,type 1374911473,I_kwDOAMm_X85R83vx,7042,Xarray returns duplicate Longitude/Latitude values with sel method ,11867798,closed,1,,,5,2022-09-15T18:18:27Z,2022-09-19T05:56:34Z,2022-09-19T05:56:34Z,NONE,,,,"### What is your issue? I am trying to select air temperature from Netcdf file and polgon regions from NUTS3 shape file with the aim of masking both to extract the values. However, for some regions, xarray returns a data frame with the same latitude or longitude values which cannot be masked by geopandas. The shape file and the netcdf I am using are zipped here Here is the code: import os import math import numpy as np import pandas as pd import matplotlib.pyplot as plt import cartopy.crs as ccrs import cartopy.feature as cfeature import seaborn as sn import geopandas as gpd import earthpy as et import xarray as xr import regionmask from sultan.api import Sultan #Plotting options sn.set(font_scale=1.3) sn.set_style(""white"") nc_file = xr.open_mfdataset('year2019.nc') #, chunks = {'time': 10}) shapefile = ""NUTS_RG_60M_2021_4326/NUTS_RG_60M_2021_4326.shp"" countries = gpd.read_file(shapefile) querry = 3 countries = countries[countries['LEVL_CODE'] == querry] ```#Select the longitude and latitude coordinates of the region of interest in the shape file.``` #These values will be passed to xarray german_state = countries[countries.NUTS_ID.isin([""DE255""])] german_state.plot() boundaries = german_state.total_bounds print(boundaries) ger_mask = regionmask.mask_3D_geopandas(german_state, nc_file.longitude, nc_file.latitude, method=""pygeos"") print(ger_mask) state_lat = [float(boundaries[1]), float(boundaries[3])] print(""Boundary Latitude"", state_lat) state_lon = [float(boundaries[0]), float(boundaries[2])] print("" Boundary Longitude"", state_lon) print(state_lat, state_lon) ```#Slice the data by time and spatial extent by passing the values selected from the shape file``` two_months_255 = nc_file[""tg""].sel( longitude=[state_lon[0], state_lon[1]], latitude=[state_lat[0], state_lat[1]], method=""nearest"") two_months_255.where(ger_mask) ```python Error: File /opt/homebrew/lib/python3.9/site-packages/xarray/core/indexes.py:449, in PandasIndex.reindex_like(self, other, method, tolerance) 445 def reindex_like( 446 self, other: PandasIndex, method=None, tolerance=None 447 ) -> dict[Hashable, Any]: 448 if not self.index.is_unique: --> 449 raise ValueError( 450 f""cannot reindex or align along dimension {self.dim!r} because the "" 451 ""(pandas) index has duplicate values"" 452 ) 454 return {self.dim: get_indexer_nd(self.index, other.index, method, tolerance)} ValueError: cannot reindex or align along dimension 'latitude' because the (pandas) index has duplicate values ``` [ask.zip](https://github.com/pydata/xarray/files/9577936/ask.zip) ","{""url"": ""https://api.github.com/repos/pydata/xarray/issues/7042/reactions"", ""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,completed,13221727,issue