Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zero-size array Erro in OrdinaryKriging #280

Open
jsbluekitty opened this issue Nov 16, 2023 · 1 comment
Open

zero-size array Erro in OrdinaryKriging #280

jsbluekitty opened this issue Nov 16, 2023 · 1 comment

Comments

@jsbluekitty
Copy link

I meet a erro like this when i use OrdinaryKriging()
zero-size array to reduction operation maximum which has no identity

My code looks like this:

Data = geopandas.read_file('./housepricepoi.shp').to_crs('EPSG:4547')

lons = Data['geometry'].x.values
lons = np.nan_to_num(lons)

lats = Data['geometry'].y.values
lats = np.nan_to_num(lats)

price = Data['price'].values
price = np.nan_to_num(price)

try:
    ok3d = OrdinaryKriging(lons, lats, price, variogram_model='linear')
    k3d1, ss3d = ok3d.execute("grid", grid_lon, grid_lat)
except Exception as e:
    print(e)

The info of data is like:

<class 'geopandas.geodataframe.GeoDataFrame'>
RangeIndex: 9920 entries, 0 to 9919
Data columns (total 2 columns):
 #   Column    Non-Null Count  Dtype   
---  ------    --------------  -----   
 0   price     9920 non-null   int64   
 1   geometry  9920 non-null   geometry
dtypes: geometry(1), int64(1)
memory usage: 155.1 KB

I wonder if it's my data that's causing the problem
if you want the data,i will send it to your email.

@jsbluekitty
Copy link
Author

And this is my new code:

Data = geopandas.read_file('./housepricepoi.shp').to_crs('EPSG:4547')
Data = Data.drop_duplicates(['geometry'])
ok3d = OrdinaryKriging(Data['geometry'].x, Data['geometry'].y, Data['price'])

k3d1, ss3d = ok3d.execute("grid", grid_lon, grid_lat)

this is the info of Data:

<class 'geopandas.geodataframe.GeoDataFrame'>
Int64Index: 1585 entries, 0 to 9877
Data columns (total 2 columns):
 #   Column    Non-Null Count  Dtype   
---  ------    --------------  -----   
 0   price     1585 non-null   int64   
 1   geometry  1585 non-null   geometry
dtypes: geometry(1), int64(1)
memory usage: 37.1 KB

it's still raise the erro:
ValueError: zero-size array to reduction operation maximum which has no identity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant