2

I am trying this example with different input files. My aim is to merge the country and point tables into one table using sjoin from geopandas and write to a CSV file. I took a look at 1. When I run the second line of code below, It takes really long time.

  1. My Input point file is about 62kb and my country file is about 8kb is that the reason for the time consumption ?
  2. Is there any other efficient way to write to a CSV? Or is there any mistake in my code below ?
merged_gdf = gpd.sjoin(point_gdf, country_gdf, how="right", op="within")
merged_gdf.to_csv("plswork.csv",index=False,mode='w')
  • 1
    OMG ,Thank you, it was indeed the geometry that delayed the processing. – roshualine Mar 7 at 13:38
1

You are including the geometries as text in the csv which can slow down the export since each vertice is written as text. If you dont need them use drop:

merged_gdf.drop('geometry',axis=1).to_csv(r'plswork.csv') 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.