Chapter 2 — Practice Spatial Vector Data with GeoPandas

GeoSense ✅
2 min readJan 6, 2023

GeoPandas library is to make working with spatial data in python easier that combining the capabilities of pandas and shapely, providing spatial operations in pandas and a high-level interface to multiple geometries to shapely.

2.1 Data Structures

GeoPandas implements two main data structures, a GeoSeries and a GeoDataFrame. These are subclasses of pandas Series and DataFrame, respectively.

a) GeoSeries

A GeoSeries is a vector where each entry in the vector is a set of shapes corresponding to one observation.

Geopandas has three basic classes of geometric objects (which are actually shapely objects): Points / Multi-Points, Lines / Multi-Lines, Polygons / Multi-Polygons.

Examples: Points, Lines and Polygons

import geopandas
from shapely.geometry import Point
s = geopandas.GeoSeries([Point(1, 1), Point(2, 2), Point(3, 3)])
s
0    POINT (1.00000 1.00000)
1 POINT (2.00000 2.00000)
2 POINT (3.00000 3.00000)
dtype: geometry
from shapely.geometry import LineString
l= geopandas.GeoSeries([LineString([Point(-77.036873,38.907192), Point(-76.612190,39.290386,), Point(-77.408456,39.412006)])])
l
0    LINESTRING (-77.03687 38.90719, -76.61219 39.2...
dtype: geometry
from shapely.geometry import Polygon
p=…

--

--

GeoSense ✅

🌏 Remote sensing | 🛰️ Geographic Information Systems (GIS) | ℹ️ https://www.tnmthai.com/medium