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

OverflowError: Python int too large to convert to C long #445

Closed
scottyhq opened this issue Nov 8, 2024 · 5 comments
Closed

OverflowError: Python int too large to convert to C long #445

scottyhq opened this issue Nov 8, 2024 · 5 comments

Comments

@scottyhq
Copy link
Contributor

scottyhq commented Nov 8, 2024

Getting this error trying to sample "esa-worldcover-10meter"

from sliderule import raster
import geopandas as gpd

region = [  {"lon": -108.34, "lat": 38.89},
            {"lon": -107.76, "lat": 38.90},
            {"lon": -107.78, "lat": 39.26},
            {"lon": -108.36, "lat": 39.25},
            {"lon": -108.34, "lat": 38.89}  ]

gfp = gpd.GeoDataFrame(geometry=gpd.points_from_xy([-108.1, -108.3], [39.1, 39.2]), crs='EPSG:4326')
points = [[x,y] for x,y in zip(gfp.geometry.x , gfp.geometry.y)]
gdf = raster.sample("esa-worldcover-10meter", points)
---------------------------------------------------------------------------
OverflowError                             Traceback (most recent call last)
Cell In[1], line 12
     10 gfp = gpd.GeoDataFrame(geometry=gpd.points_from_xy([-108.1, -108.3], [39.1, 39.2]), crs='EPSG:4326')
     11 points = [[x,y] for x,y in zip(gfp.geometry.x , gfp.geometry.y)]
---> 12 gdf = raster.sample("esa-worldcover-10meter", points)
     13 gdf

File ~/GitHub/uw-cryo/coincident/.pixi/envs/dev/lib/python3.12/site-packages/sliderule/raster.py:145, in sample(asset, coordinates, parms)
    143 per_coord_index += 1
    144 for raster_sample in input_coord_response:
--> 145     columns['time'][i] = numpy.int64((raster_sample['time'] + 315964800.0) * 1000000000)
    146     columns['longitude'][i] = numpy.double(longitude)
    147     columns['latitude'][i] = numpy.double(latitude)

OverflowError: Python int too large to convert to C long
elidwa added a commit that referenced this issue Nov 18, 2024
@elidwa
Copy link
Contributor

elidwa commented Nov 18, 2024

Fixed in PR #447

@scottyhq
Copy link
Contributor Author

scottyhq commented Dec 5, 2024

Thanks @elidwa ! Looks like this can be closed after a 4.8.15 release?

@scottyhq
Copy link
Contributor Author

scottyhq commented Dec 6, 2024

On the topic, I'm also unsure what is the worldcover.time unit for 1309046418000.0? I'm not sure how to convert that to a human readable timestamp...

@elidwa
Copy link
Contributor

elidwa commented Dec 6, 2024

@scottyhq the worldcover.time value 1309046418000.0 is GPS time in seconds. Unfortunately, Open Data on AWS only hosts TIFF files and does not provide any STAC endpoint or VRT file. Because of this, we generate the VRT file from their data and host it in our SlideRule S3 buckets. The process for this is detailed in the README file, with the top sections specifically describing the ESA worldcover portion:
https://github.com/SlideRuleEarth/sliderule/blob/main/datasets/opendata/utils/build_vrt_readme.txt

Since we create the VRT, the date of creation would not make much sense as a time reference. Instead, for time, we chose the midpoint of 2021.

1309046418000.0 = TimeLib::datetime2gps(2021, 06, 30, 0, 0, 0) / 1000

@scottyhq
Copy link
Contributor Author

scottyhq commented Dec 17, 2024

Closed for server version>=4.8.15

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

2 participants