4

It is easy to save a GeoPandas dataframe to a PostGIS database using the gdf.to_postgis(...) command. But, it is not clear to me if it automatically generates spatial indices or if these need to be created after the data is loaded into the database?

If it needs to be generated separately, does GeoPandas have a command or do you need to use a different interface to the PostGIS database (e.g., GeoAlchemy, etc)?

3
  • 1
    Have you tried using to_postgis() and having a look at the resulting table? Seems like the easiest way to find out
    – Joe Be
    Commented Oct 13, 2022 at 15:12
  • @Joe Be Thanks, but I haven't been able to confirm. I used this solution (gis.stackexchange.com/questions/241599/…) to find all tables that do not have a spatial index but it returns nothing. But, I suspect that they are not there. How do I check?
    – jtam
    Commented Oct 13, 2022 at 17:20
  • You can inspect the created table sql query in pgadmin or alternatively print to your terminal using pg_dump -t 'schema-name.table-name' --schema-only database-name
    – Joe Be
    Commented Oct 17, 2022 at 10:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.