-
Notifications
You must be signed in to change notification settings - Fork 27
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
Query population usign city boundaries to avoid loading all country data #30
Comments
Hello! Question: the mask parameter should always receive a polygon, right? |
Hello @jeronimoluza , that's awesome. Thanks for the help. Feel free to make a PR 🚀. |
Hi @Claudio9701!
Do you have any advice that can help me build the required workspace? |
Hi @jeronimoluza Thanks for your help. Could you try the following steps to setup the workspace: Project Setup Instructions
|
I'm able to create the environment using Python3.12, but unable to do so using Python 3.6 – I get a lot of dependency conflicts.
|
Hi @Claudio9701, I resumed this after a week, and I realized I was having a bad function call inside one of my testing scripts 🥲. After playing around for a bit, I found that this next method (without generating urls = resources_df.loc[ids, "url"]
print(urls)
if isinstance(ids, list) and len(ids) > 1:
df = pd.concat([pd.read_csv(url) for url in urls])
else:
df = pd.read_csv(urls)
if mask:
if isinstance(mask, GeoDataFrame):
mask = mask.unary_union
minx, miny, maxx, maxy = mask.bounds
df_filtered = df[
(df["longitude"] >= minx)
& (df["longitude"] <= maxx)
& (df["latitude"] >= miny)
& (df["latitude"] <= maxy)
]
return df_filtered
else:
return df The only problem is that is not as precise as when returning the points – the intersection method will return the points that intersect with the mask, while this "bounds" method will return all the points inside the extent of the mask. What do you think? |
That's awesome, thanks! I like that solution we can do the bounding box filter and then apply clip to the result. Another option could be to read the geotiff instead of the csv from the hdx. Geotiffs can be queried directly when reading using rasterio. I would say we close this issue with the first solucion (bounds+clip) and think if it's worth it to handle geotiffs later. I'm working on a function to bring FABDEM raster data into urbanpy |
Just implemented and tested the bounds + clip solution! Sending a pull request now. |
Currrent behaviour:
Requested feature:
Where
city_limits
represent either the city boundaries as a polygon or the city total bounds as a bounding box.The text was updated successfully, but these errors were encountered: