Boundless PostGIS Tutorial

The Boundless PostGIS workshop is an excellent introduction to PostGIS. It can be argued that it is dated, but I think the fundamentals are still very valid. However maintaining a free course is quite an overhead for any company. So I don’t blame them from taking it down, and no longer hosted it on the Boundless website.

However it was released under a creative commons license and the source is easily available on GitHub, and can be easily built.

You can find a hosted version on: GISforThought.com/projects/postgis_tutorial/

The data can be found in my previous post: GISforThought.com/postgis-tutorial-data/

PostGIS Tutorial Data

The OpenGeo (now called Boundless) PostGIS tutorial has long been my recommendation for people just getting started with PostGIS. It provides a broad intro to PostGIS, great for users new to SQL.

Unfortunately they recently removed it from their website. The guide was a fairly old now, so I don’t blame them. But it was a great free resource.

I have created a version of the data used, which can be accesses at (choose the green Clone or download button and Download ZIP):

https://github.com/HeikkiVesanto/postgis_course_data

The data is also not 100% the same as the original. So some of the queries will have to be modified. Particularly the neighborhoods are different. So they may have slightly different names/boundaries/capitalization. So keep that in mind when creating your queries, and interpreting the results. But overall the data is pretty similar

The course has been compiled and can be found at: https://gisforthought.com/boundless-postgis-tutorial/

Copying Rasters in PostGIS

I ran into a process where I wanted to create copies of rasters in PostgreSQL. While seemingly a simple process this took me a bit of work to figure out.

For my workflow I had three rasters, which all have the same size, and I want to load them into the same PostGIS table with three raster geometry columns. I don’t think this will work for different sized rasters since the rid’s will not match.

Three rasters:
raster1
raster2
raster3

Which I want to copy into:
merged_raster

First to create the merged raster table:

Then to add the rid’s. These are the id’s of the tiles that the raster was split into when loading. If your tile size is large enough then you may only have one.

Then copying the actual data is straighforward (this assumes the raster column in the raster1 datasets is called rast):

Now I still have an issue that QGIS will not load these layers. It will always load the initial raster column no matter what is chosen.

Anaconda install with OSGeo4W

I was coming across some errors when installing Anaconda, Miniconda specifically.

https://conda.io/miniconda.html

I think part of the reason is I have quite a few installs of Python due to OSGeo4W.

My error:

The solution:

Update the activate.bat file that is called when launching from the start menu. For me located in:

We need to add in the following to clear out and reset the python environment before launching anaconda:

So, editing the file from:

To:

Updating the paths as required.

This just clears out the python and windows environmental variables before launching, similar to what OSGeo4W does.