-
Book Overview & Buying
-
Table Of Contents
Geospatial Analysis with SQL
By :
Understanding how spatial statements are constructed and how to customize them for your queries is an important task in learning new ways to interact with spatial datasets.
The synopsis of ST_Within includes the following:
boolean ST_Within(geometry A, geometry B);
A true and false determination is provided to determine if geometry A is entirely within geometry B.
You will need to be comfortable with SELECT statements. Consider the following code. I am interested in buildings located within protected areas. I need to SELECT the buildings and would like to identify them by their name and fid. Geopackages often use fid as their unique identifier, although it isn’t often necessary since OSM has its own identification for its features. I grabbed it here as an example. Any unique identifier will work. I ran the following query in pgAdmin.
The name, fid, and geometry (point) are displayed in the output window once you run the code. ST_AsText...