Loading and Querying Datasets
Loading and querying spatial datasets from vector files or PostGIS.
Mundipy supports loading and querying any vector dataset supported by GDAL and tables from PostGIS. This includes Shapefiles, GeoJSON, FlatGeobufs, and KMLs, with a full list of drivers available here.
Loading vector datasets
Files from disk
Passing a filename as the first argument loads a vector file from disk:
Files over http/https
Mundipy will automatically download relevant parts of a remote file when you pass a URL:
PostGIS table
To download from a PostGIS table, pass the connection URL along with the table name:
If a loaded dataset is from PostGIS or is a Shapefile or FlatGeobuf, we can use the spatial index to query a subset of the data.
Querying datasets
Intersection
We can get a list of geometries that intersect with a given geometry by
using ds.intersects(geom)
.
Nearest
This returns the geometry that is closest to the given geometry. Useful for nearest neighbor queries.
Returns None
if the dataset is empty.
Within
Returns a list of geometries that fall within a certain radius of the given geometry.
Useful for finding all of the points of interest near an area. Geometry does not have to be a Point
.
This is equivalent to calling ds.intersects(geom.buffer(1200))
.