Last active
March 31, 2022 04:09
-
-
Save rchardptrsn/bc32a536e114b85d1cc41312759bc7f5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import geopandas as gpd | |
from sqlalchemy import create_engine | |
# create the sqlalchemy connection engine | |
db_connection_url = "postgresql://user:password@localhost:5432/gis_db" | |
con = create_engine(db_connection_url) | |
# read in the data | |
gdf = gpd.read_file('shapefile/holc_ad_data.shp') | |
# Drop nulls in the geometry column | |
print('Dropping ' + str(gdf.geometry.isna().sum()) + ' nulls.') | |
gdf = gdf.dropna(subset=['geometry']) | |
# Push the geodataframe to postgresql | |
gdf.to_postgis("redlining", con, index=False, if_exists='replace') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment