PostgreSQL and Fuzzy Hashes– a natural combo?

A while back, I had the idea of creating a hash of geometry in order to create a unique constraint on geometry to avoid duplicate geometries in a PostGIS table. It works. It’s slow, but it works. I haven’t used it since. What I really wanted to do though was be able to detect if geometries were similar as well (not just detect identical geometries), … Continue reading PostgreSQL and Fuzzy Hashes– a natural combo?

The PostGIS learning Curve: ST_Within and ST_Crosses

In an earlier post, I was frustrated with the intersection of a polygon and line datasets coming out as a geometry collection instead of a simple line dataset as expected. Nicklas Avén was kind enough to point out that this is a natural consequence of the logic of an intersection, the definition of ST_Intersects is: Returns TRUE if the Geometries/Geography “spatially intersect” – (share any … Continue reading The PostGIS learning Curve: ST_Within and ST_Crosses

Geometry Collections and Small Headaches

The disk that held the personal geodatabases of our contour datasets died a while back, but not before I loaded the contours into PostGIS and started serving them up. Our new intern is working on putting together some shapefiles layer groups in ArcGIS for map production, and asked for a missing one… . I don’t have it, but in principle can always extract it from … Continue reading Geometry Collections and Small Headaches

Shapfile spatial indices and PostGIS dumps

Another short post… . I have in place a framework for maintenance of our boundary data that works really well. I feed an edited shapefile into the database, and PostGIS creates all the versions of the boundary that need created. The database then exports the managed data to shapefile so there is a database version and a shapefile version depending on need. When all was … Continue reading Shapfile spatial indices and PostGIS dumps

pgagent — when triggers are too much

This will be one of my shorter posts. pgadmin III allows for the development of scheduled tasks that run on your PostgreSQL database. As my PostGIS triggers have gotten more complicated, and since they run per transaction to keep ACID compliance, a big mess can be made by just updating a dataset (this is what vacuum is good for), and the time for inserts can … Continue reading pgagent — when triggers are too much

Multi-ring buffers in PostGIS

I maintain a lot of versions of our exterior property boundary layer for our park system for different purposes, e.g. this post.  What I’d like to include in this automatically managed dataset is a multi-ring buffer version of the dataset for the purpose of a careful mask with fade (also useful for showing coastal vignettes— oops, ESRI link), e.g.: So, first we buffer: And discover … Continue reading Multi-ring buffers in PostGIS

Cost of nearest neighbor search depending on distance

A quick review of costs to search with increasing distances.  Reference this original post for the code being run. SELECT DISTINCT ON(g1.gid)  g1.gid as gid, g2.gid as gid_ground, g1.x as x, g1.y as y, g2.z as z, g1.z – g2.z as height, g1.the_geom as geometry FROM veg As g1, ground As g2    WHERE g1.gid <> g2.gid AND ST_DWithin(g1.the_geom, g2.the_geom, 3.5)    ORDER BY g1.gid, … Continue reading Cost of nearest neighbor search depending on distance

Further optimization of the PostGIS LiDAR Vegetation Height Query

There’s much to be said for knowing your data in order to best optimize the analysis of it.  Beyond all other bits of cleverness, having a functional understanding of your problem is the first step toward conceiving an intelligent and efficient solution. One thing that I didn’t do two posts ago was to spend any time deciding how far out the search for nearby points … Continue reading Further optimization of the PostGIS LiDAR Vegetation Height Query