• 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 (24)
  • Essay (1)
  • Podcast (3)
  • Tutorial (5)

Recent posts

  • Get Featured in the 2025 Geospatial Landscape Report (Submit Your Company Today)
  • Apache Sedona Tutorial: Scalable Spatial Joins and Geospatial Processing with Spark
  • BigQuery vs. Wherobots: What a 23-Second Difference in Spatial SQL Really Reveals

Tags

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

Related posts

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 […]

Article

The Top 11 Open GeoParquet Datasets: Making big geospatial data easy

January 18, 2024 Matt Forrest Comments Off on The Top 11 Open GeoParquet Datasets: Making big geospatial data easy

In the dynamic field of geospatial technology, the evolution of data formats plays a pivotal role in shaping how we interact with and interpret spatial information. The advent of GeoParquet has marked a significant milestone, offering a more efficient and accessible way to handle large spatial datasets. This blog post delves into a comprehensive exploration […]

Spatial Lab
  • Join the Spatial Lab community
Courses
  • Learn Modern GIS with courses and certifications
Spatial SQL
  • Get the Spatial SQL book today
Join Us

© Matt Forrest 2024. All Rights Reserved.