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

tessellation not recognized as a gpd.GeoDataFrame #284

Open
MehdiAbarro opened this issue Apr 25, 2024 · 3 comments
Open

tessellation not recognized as a gpd.GeoDataFrame #284

MehdiAbarro opened this issue Apr 25, 2024 · 3 comments

Comments

@MehdiAbarro
Copy link

MehdiAbarro commented Apr 25, 2024

Hello,

I have an issue creating a FlowDataFrame: my tessellation is not recognized as a gpd.GeoDataFrame.
Here is how I define my tessellation and my flow data:
2024-04-25 09_29_08-● pre_post ipynb - PV-Lab_project - Visual Studio Code

Then OD = skmob.FlowDataFrame(data=OD_flows, tessellation=tessellation, tile_id='tile_ID') raises : "TypeError: tessellation must be a GeoDataFrame with tile_id and geometry."

@me9hanics
Copy link

Because the thrown error is TypeError, I believe the issue may be that one of your columns has a different type than required. At the end of your code, check the data types with tessellation.dtypes of both columns, first should be int64, second should be geometry. It may even happen that it has issues with OD_flows and the stored datatypes (I had these issues just yesterday for a created FDF), in that case, do this:
fdf['origin'] = fdf['origin'].astype('int64')
fdf['destination'] = fdf['destination'].astype('int64')
fdf.tessellation[constants.TILE_ID] = fdf.tessellation[constants.TILE_ID].astype('int64')
(constants come from from skmob.utils import utils, constants).

Maybe not having a coordinate reference system for the GeoDataFrame causes the issue? Might have problems with "interpreting" the geometry. Try tessellation.crs="EPSG:4326" (or even better would be taking the CRS of ch_geo) after turning it into a GDF in line 2.

One last thought is that maybe you might also need a population column, from the example here. If that is the case, the developers should make it clear when throwing error.

@MehdiAbarro
Copy link
Author

Thank you for your answer!

Sadly, even after checking everything you mentioned I am not sure why the error raises.
2024-05-05 18_11_14-● ch_mobility ipynb - PV-Lab_project - Visual Studio Code
2024-05-05 18_11_37-● ch_mobility ipynb - PV-Lab_project - Visual Studio Code

I still have the same error raised when doing OD = skmob.FlowDataFrame(data=OD_flows, origin='origin', destination='destination', flow='flow', tessellation=tessellation, tile_id='tile_id').

What is even weirder is that when I try to run the provided example the same error raises.
2024-05-05 18_14_11-● ch_mobility ipynb - PV-Lab_project - Visual Studio Code

@MehdiAbarro
Copy link
Author

MehdiAbarro commented May 11, 2024

Still have the same issue, not sure what I should do...
When checking the logs I noticed that this is the snippet where the error is raised:
`if not isinstance(data, pd.core.internals.BlockManager):

        self[constants.ORIGIN] = self[constants.ORIGIN].astype('str')
        self[constants.DESTINATION] = self[constants.DESTINATION].astype('str')

        if tessellation is None:
            raise TypeError("tessellation must be a GeoDataFrame with tile_id and geometry.")`

So my geodataframe tessellation is considered to be None even though it clearly is not. The default input for the tessellation parameter is None so I guess the FlowDataFrame class ignores my geodataframe ?

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