Showing posts with label geojson. Show all posts
Showing posts with label geojson. Show all posts

Wednesday, July 7, 2021

Tips on GeoPandas

According to the documentation in GeoPandas, the following codes could read a local GeoJSON file and import to a PostGIS DB:


import geopandas

from sqlalchemy import create_engine


path_to_data = "./my_file.geojson"

gdf = geopandas.read_file(path_to_data)


db_connection_url = "postgres://user:pwd@localhost:5432/db";

engine = create_engine(db_connection_url)

gdf.to_postgis("my_file_table", con=engine)


I found the following tips:

  • "postgres://" has to be changed to "postgresql://"
  • Package "psycopg2" is required together with "sqlalchemy" (Details could be found in DBAPI support section in PostgreSQL documentation)
  • Package "GeoAlchemy2" is required together with "sqlalchemy"
Enjoy!

CSP on Apache

To add CSP to root if sort of funny. The following will NOT work for most cases !!     <LocationMatch "^/$">        Header s...