• Posts
  • Spatial Lab
  • Modern GIS Accelerator
  • The Spatial SQL Book

Get the newsletter

Join 71,000+ geospatial experts growing their skills and careers. Get updates on the most cutting edge updates in modern GIS and geospatial every week.

Edit Content
  • LinkedIn
  • YouTube
Tutorial

PostGIS and GeoPandas in Jupyter in 4 minutes

January 15, 2022 Matt Forrest Comments Off on PostGIS and GeoPandas in Jupyter in 4 minutes
PostGIS and Geopandas

Take advantage of the speed of PostGIS along with the flexibility of Geopandas and Python in 4 minutes! Take a look at the video and follow along with these steps!

The Spatial SQL Book – Available now!

Check out my new book on Spatial SQL with 500+ pages to help you go from SQL novice to spatial SQL pro.

Buy now!

First, install your libaries

You will need to install Geopandas and psycopg2 (you can also use SQLAlchemy) in your Jupyter notebook environment. If you are using a local version of PostGIS make sure you are also running your notebook locally!

You can use the following command:

!pip install geopandas psycopg2

Import your libraries

You next need to import your libraries. You can also use an alias so you don’t have to type them each time.

Establish your database connection

Next you can connect your database using your database host and other parameters. Check the docs for more detials.

Use Geopandas to query against your database

You are ready to query your database and create a GeoDataFrame! It is super easy because Geopandas has a built-in function for this called from_postgis. Just pass in a query and your database connection variable, and go!

Now give it a shot with some other queries! You can also check out my guides and resources for spatial SQL (over 40 resources) and geospatial Python (over 75 resources)!

  • Python
  • Spatial SQL
Matt Forrest

Post navigation

Previous
Next

Search

Categories

  • Article (26)
  • Essay (1)
  • Podcast (4)
  • Tutorial (5)

Recent posts

  • Breaking the GIS Silo: Why GeoParquet and Iceberg are the key to Spatial Analytics at Scale
  • How to Build a Cloud-Native Spatial Data Lakehouse
  • How Cloud Storage Powers Cloud-Native Geospatial, AI, and Analytics

Tags

aggregations Apache Airflow Apache Iceberg Apache Sedona bigquery Cloud-Native Geospatial Cloud GIS Cloud Optimized GeoTIFF duckdb geoparquet geospatial gis Modern GIS postgis Python snowflake Spatial SQL sql Wherobots zip codes

Related posts

Podcast

Breaking the GIS Silo: Why GeoParquet and Iceberg are the key to Spatial Analytics at Scale

July 3, 2025 Matt Forrest No comments yet

For decades, GIS has lived in a world of its own. Specialized software. Obscure formats. A profession that, despite being critical to everything from climate modeling to logistics, has remained siloed from the rest of the data world. But that’s finally starting to change. In the latest episode of the Spatial Stack podcast, I sat […]

Article

Scaling GIS Workflows with COGs, Airflow, and Apache Iceberg

April 25, 2025 Matt Forrest Comments Off on Scaling GIS Workflows with COGs, Airflow, and Apache Iceberg

TOP OF THE STACK What we need to do with COGs COGs (Cloud-Optimized GeoTIFFs) are one of the most promising tools we have for making raster data truly cloud-native. They let you stream just the pieces you need, work remotely, and plug into modern geospatial systems without downloading giant files. But after working closely with […]

Article

From Desktop GIS to Cloud: A Beginner’s Roadmap to Modern GIS Tool

March 7, 2025 Matt Forrest Comments Off on From Desktop GIS to Cloud: A Beginner’s Roadmap to Modern GIS Tool

Modern GIS is changing fast. If you’ve been working with QGIS, ArcGIS, or any other desktop GIS tool, you’ve probably hit some limitations—datasets getting too big, processing times slowing down, and collaboration becoming a challenge. The good news? The cloud offers a way forward. But how do you make that transition? How do you go […]

Spatial Lab
  • Join the Spatial Lab community
Policies
  • Privacy Policy
  • Terms & Conditions
Spatial SQL
  • Get the Spatial SQL book today
Join Us

© Matt Forrest 2024. All Rights Reserved.