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

About RTree Data Structure Persistent Storage #284

Closed
RuoCJ opened this issue Sep 27, 2023 · 3 comments
Closed

About RTree Data Structure Persistent Storage #284

RuoCJ opened this issue Sep 27, 2023 · 3 comments

Comments

@RuoCJ
Copy link

RuoCJ commented Sep 27, 2023

I wanted to persist the built Rtree in my code, but what was stored was an empty pickle file. The code is as follows:

import rtree
import pandas as pd
import pickle
spatial_index = rtree.index.Index()

df = pd.read_csv("block_loc", sep='\t')

for i, row in df.iterrows():
	id = int(row[0])
	longitude = float(row[1])
	latitude = float(row[2])
	print(id, longitude, latitude)
	spatial_index.insert(id, (longitude, latitude))
print(spatial_index)
with open("spatial_index.pickle", "wb") as f:
	pickle.dump(spatial_index, f)

Rtree object:rtree.index.Index(bounds=[-150, 38, 150, 40], size=689274)

Objects read from pickle file:rtree.index.Index(bounds=[1.7976931348623157e+308, 1.7976931348623157e+308, -1.7976931348623157e+308, -1.7976931348623157e+308], size=0)

Why is this

@adamjstewart
Copy link
Collaborator

See #87, pickling is currently broken, fixes would be very appreciated.

@RuoCJ
Copy link
Author

RuoCJ commented Sep 27, 2023

See #87, pickling is currently broken, fixes would be very appreciated.

Excuse me, do you want me to try fixing this bug?

@adamjstewart
Copy link
Collaborator

If you can that would be great. I tried in #197 but couldn't come up with a satisfying solution.

@RuoCJ RuoCJ closed this as completed Oct 27, 2023
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