Introducing Crunchy Data Warehouse: A next-generation Postgres-native data warehouse. Crunchy Data Warehouse Learn more

Latest posts from Paul Ramsey

  • 6 min read

    Waiting for PostGIS 3.2: ST_Contour and ST_SetZ

    Paul Ramsey

    One theme of the 3.2 release is new analytical functionality in the raster module, and access to cloud-based rasters via the "out-db" option for rasters. Let's explore two new functions and exercise cloud raster support at the same time. Can you believe that there is a complete raster data set of all SRTM elevation data online, in cloud optimized GeoTIFF format? It's true, there is (and much more), at OpenTopography ! The SRTM data set is a collection of 14380 files, with a pixel size o...

    Read More
  • 4 min read

    Waiting for PostGIS 3.2: ST_MakeValid

    Paul Ramsey

    One of the less visible improvements coming in PostGIS 3.2 (via the GEOS 3.10 release) is a new algorithm for repairing invalid polygons and multipolygons. Algorithms like polygon intersection, union and difference rely on guarantees that the structure of inputs follows certain rules. We call geometries that follow those rules "valid" and those that do not "invalid". The rules are things like: • Polygon rings should not cross themselves • Polygon rings should not cross other rings • Multipol...

    Read More
  • 4 min read

    Cut Out the Middle Tier: Generating JSON Directly from Postgres

    Paul Ramsey

    Too often, web tiers are full of boilerplate that does nothing except convert a result set into JSON. A middle tier could be as simple as a function call that returns JSON . All we need is an easy way to convert result sets into JSON in the database. PostgreSQL has built-in JSON generators that can be used to create structured JSON output right in the database, upping performance and radically simplifying web tiers. Fortunately, PostgreSQL has such functions , that run right next to the data...

    Read More
  • 4 min read

    Waiting for PostGIS 3.2: ST_InterpolateRaster

    Paul Ramsey

    A common situation in the spatial data world is having discrete measurements of a continuous variable. Every place in the world has a temperature, but there are only a finite number of thermometers: how should we reason about places without thermometers and how should we model temperature? For many use cases, the right way to model a continuous spatial variable is a raster: a regularly spaced grid where each square in the grid contains a value of the variable. This works for temperature and prec...

    Read More
  • 6 min read

    (The Many) Spatial Indexes of PostGIS

    Paul Ramsey

    Spatial indexes are used in PostGIS to quickly search for objects in space. Practically, this means very quickly answering questions of the form: • "all the things inside this this" or • "all the things near this other thing" "all the things inside this this" or "all the things near this other thing" Because spatial objects are often quite large and complex (for example, coastlines commonly are defined with thousands of points), spatial indexes use "bounding boxes" as index and search keys: •...

    Read More
  • 6 min read

    Performance Improvements in GEOS

    Paul Ramsey

    We at Crunchy Data put as much development effort into improving GEOS as we do improving PostGIS proper, because the GEOS library is so central to much geospatial processing. The GEOS library is a core piece of PostGIS. It is the library that provides all the "hard" computational geometry functionality: • Intersections of geometry • Unions of geometry • Differences of geometry • Buffers of geometry • Geometry relationship evaluation Intersections of geometry Unions of geometry Differences of...

    Read More
  • 6 min read

    Fuzzy Name Matching in Postgres

    Paul Ramsey

    A surprisingly common problem in both application development and analysis is: given an input name, find the database record it most likely refers to. It's common because databases of names and people are common, and it's a problem because names are a very irregular identifying token. The page " Falsehoods Programmers Believe About Names " covers some of the ways names are hard to deal with in programming. This post will ignore most of those complexities, and deal with the problem of matching up...

    Read More
  • 3 min read

    Production PostGIS Vector Tiles: Caching

    Paul Ramsey

    Building maps that use dynamic tiles from the database is a lot of fun: you get the freshest data, you don't have to think about generating a static tile set, and you can do it with very minimal middleware, using pg_tileserv . However, the day comes when it's time to move your application from development to production, what kinds of things should you be thinking about? Let's start with load . A public-facing site has potentially unconstrained load. PostGIS is fast at generating vector tiles.

    Read More
  • PostGIS Raster and Crunchy Bridge

    Paul Ramsey

    The PostGIS raster extension has a steep learning curve, but it opens up some unique possibilities for data analysis and accessing non-standard data from within PostgreSQL. Here's an example that shows how to access raster data from PostGIS running on Crunchy Bridge . The raster data type in PostGIS can be used to store any kind of raster data: images, elevation grids, model outputs, and more. One band, four band, multi-band and anything in between. This flexibility leads some beginners to du...

    Read More
  • 4 min read

    Waiting for PostGIS 3.1: GEOS 3.9

    Paul Ramsey

    While we talk about " PostGIS " like it's one thing, it's actually the collection of a number of specialized geospatial libraries, along with a bunch of code of its own. • PostGIS provides core functionality bindings to PostgreSQL, the types and indexes format reading and writing basic algorithms like distance and area performance tricks like caching simple geometry manipulations (add a point, dump rings, etc) algorithms that don't exist in the other libraries • bindings to PostgreSQL, the type...

    Read More