Skip to content

improved gadm setup with reworked pipe #448

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

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

aagm
Copy link
Member

@aagm aagm commented May 22, 2025

please review the generated files, so now i create a csv with hex wkb and the sql upsert statements

@aagm aagm requested a review from alexeh May 22, 2025 11:56
Copy link

vercel bot commented May 22, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
tnc-blue-carbon-cost-tool-ghps ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 22, 2025 11:56am

@agnlez agnlez added the data label May 22, 2025
simplification_tolerance, preserve_topology=preserve_topology
# we ensure that the areas of this countries match the area used in the excel sheet
country_size_ha = {
"USA": 947084624.2706754,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems evil. Why are we hardcoding areas for specific countries?

I guess these countries are the ones that we can now calculate stuff for.

What happens whenever the client gets more data for additional countries? We will be using the values computed below. It does not seem right

Copy link
Member Author

@aagm aagm May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I said I don't want to risk that due to the country area numbers are different, the only way is using the same harcoded numbers Elena has. Where did she got them? No idea as is not in the original excel. The other country areas are calculated using an equal area projection.


def generate_sql_insert(rows: str) -> str:
return f"""
INSERT INTO public.countries
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we were using UPSERT?

Is it safe to only update the area (hardcoded or precomputed) and the geom:

Copy link
Member Author

@aagm aagm May 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As far as I know an upsert in Postgres is resolve as an insert on conflict statement.



# 5. Write SQL to a file
def write_sql_file(merged_gdf, output_file):
def write_sql_file(merged_gdf: gpd.GeoDataFrame, output_file: str) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this file being saved? Can't see any path reference so I assume it is writing it in the current path

However the new file is under /data/excel. Is this the correct location?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the sql statement is, the csv in in the raw_data/gadm folder.

Copy link
Collaborator

@alexeh alexeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the file. It's A LOT bigger now, is this ok?

Also, I have left some comments. I am concerned specially with the hardcoded area_ha values just for specific countries

@aagm
Copy link
Member Author

aagm commented May 23, 2025

let me know if the explanations are enough

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

Successfully merging this pull request may close these issues.

3 participants