Posts

Looking back at 2019 Geospatial Python

Image
It was a busy year in 2019, except for a short holiday in July. 2019 came and went.  Lets begin with how my tech stack changed in 2019. Technology Stack as of December 2019 The basic core has not changed in the last several years, including Python, PostGIS, Postgresql.  What is new this year is Google Cloud.  Google Cloud Storage and Compute Engine were front and center this year for my new applications and deployments.  The experience was smooth and polished in comparison to the AWS world which is also getting better I may add.  Azure is looking good aswell, and I am looking forward to seeing what happens in 2020 within these big 3 players.   GDAL in 2019 Installation of geospatial libraries was still a pain in 2019.  Docker of course makes this pain less painfull but nonetheless I do not feel comfortable in saying that getting GDAL to jive with your application stack works out of the box.  I was hoping this would be a solved problem but if you scour the internet t

Integrate Mapillary viewer with Openlayers side by side

Mapillary offers several examples of integrating web mapping clients, but Openlayers is missing.  I thought it was time to add Openlayers to that list. In this example I created a map icon using two font codes from font-awesome.  The point feature is then placed on top of the OpenStreetMap basemap.  Updating the position of the icon happens when you click the controls within the mapillary viewer.  If you click on the image locations on the map the mapillary viewer will automatically update.   The icon bearing also adjust correctly to the camera bearing values. See the Pen sync mapillary with openlayers full working example by Michael Diener ( @mdiener21 ) on CodePen .

Find a string in a Postgresql text array of strings

The problem:   You want to find or match a string that is located in a Postgresql text string array. The text array of stings could look like this {Restroom, Locker, Entrance} . In this example the table called " places "  has a column called " tags " that is our Postgresql text arrray. The query you would want to use to find all Restrooms without having to have an exact match but use a like statement could look like this: Select array_to_string(tags,';') from places where array_to_string(tags,';') like '%Rest%'; This will find all entries that match only the first for characters in Restroom If you want to do this in Django as a raw query your query statement would look like: Places.objects.raw("""Select id, array_to_string(tags,';') from appName_places where array_to_string(tags,';') like %s',['%Rest%']"""):

Stack font awesome icons with openlayers

Image
I'm using fontawesome 4.7 and openlayers 5.2 in my project and wanted to create the stacked icon effect.  Basically I want to have two font icons on top of each other.  My code example is using a red circle for the background and a black flag for the foreground. My first codepen attempt worked out not so bad: NOTE this is broken for openlayers versions 4.4.+ to 4.6.5: OL BUG fix https://github.com/openlayers/openlayers/issues/7675 **CLICK RERUN**   bottom right inside codepen if you cannot see a red circle with a flag See the Pen stack font-awesome fonts openlayers by Michael Diener ( @mdiener21 ) on CodePen . If you just want to see the javascript part I also created a github gist CODE

My Geo Web Application Development Tech Stack

I thought that it would be interesting to post a list of technologies that I use in my so called "technology stack".  The day to day work happens in Ubuntu, PyCharm, Visual Studio Code, Postgresql (PgAdmin 4) all from my Dell XPS 15 9560. My old Dell Precision m4500 lasted 7 years until the harddrive failed.  It is still alive with a new 512 GB SSD and running Ubuntu, sorry Windows.

How to backup Postgresql DB to an FTP site using Python

Using the standard tools of Postgresql pg_dump and Python's subprocess module we can call the command line tool via Python and have the dump file uploaded to an FTP site.  This is of course a very simple way to backup. An alternative would be to use  Pgbarman https://www.pgbarman.org/ which is a higly effective way to minimize data loss. Here you go:

How to create a regular survey grid with PostGIS

Image
A fishnet grid is also commonly called a: survey grid, raster sample, sample grid, grid, landscape grid, grid reference and of course fishnet. source:  https://trac.osgeo.org/postgis/wiki/UsersWikiCreateFishnet It all depends on your field of expertise as to what you call it, I know some times in biology they use the term "landscape grid". If you are the data analyst, gis analyst or even coop student who is assigned the job of creating such a sample grid as a set of polygons using Postgresql with PostGIS here is the function you could create in the database. As you see in the GIST here there is also sample sql select query that would generate the data for you using the default start location of x= 0.0 and y=0.0. The input parameters are as follows: number of rows of the grid number of columns of the grid start x coordinate (optional, default is 0.0) start y coordinate (optional, default is 0.0) row width in meters (if coordinates are a meter based syste