Posts

Make networkx Delaunay graphs from geopandas dataframes

23 January 2023

Geopandas Geodataframes store spatial data such as points and polygons. This post adapts code a from some examples online to show how to convert spatial points into a Delaunay graph. This is a undirected graph with edges between adjacent points only. This may be useful for building a spatial contact network of neighbouring points and doing further processing. Here we convert into networkx graphs. First we make a GeoDataFrame from some random points: def random_points(n): import random # Create an...

Read more...

Using Molecular Nodes in Blender to visualise proteins

14 January 2023

Blender is a free program capable of advanced 3D modelling, animation and rendering. It is used to create photo realistic images for many applications such as animated films or architecture. I used to be interested in using Blender to create images of proteins and other molecules. This was a rather convoluted process. It seems things have moved on since I last looked at this area. There is now a very useful addon called Molecular Nodes that can import and render...

Read more...

Scrape dynamic tables in Python with Playwright

29 December 2022

Sometimes it’s necessary to scrape a website or some pages that contain elements generated dynamically, often via javascript. This means you can’t always get all the html content in the page directly from the url. You may have to simulate interaction in the browser like clicking a button on a form and then waiting to get the content. This can be done with the Playwright library which was created to support automated testing of websites. Note that some websites won’t...

Read more...

Can ChatGPT solve bioinformatic problems with Python?

21 December 2022

There has been a lot of talk about OpenAI’s new technology, ChatGPT. This is basically a very advanced chatbot. How it works is beyond my ability to explain. It is trained on a huge amount of information from the internet and can answer general questions or write poems and essays. It can also code in virtually any language quite well. You will see plenty of youtube videos marvelling at it’s ability to produce (sometimes) usable code upon description of a...

Read more...

DALLE-2 and AI generated art.

19 December 2022

DALL-E 2 (or just dalle) is an AI model from OpenAI used to generate art and imagery from text entered by humans. It is ‘a generative language model’ that takes sentences (called prompts) and creates corresponding original images. The actual method I cannot explain as I do not understand it well enough. Basically, it appears to be made of two models. One that converts the semantic meaning of some text into a vector space that is an image representation (CLIP)....

Read more...

How to host your podcast with github

15 October 2022

If you want to make your own podcasts the usual method is probably to use a commercial service that handles all the file hosting and distribution. However the process is actually surprisingly simple for those with a bit of technical knowledge and patience. Web standards are really the key to how podcasting works. RSS (Really Simple Syndication) and its offshoot Atom are how sites create a ‘feed’ that indicates when updates are made. RSS is just XML-formatted plain text. This...

Read more...

Excess mortality in Ireland is still high in 2022

08 September 2022

In a previous post I showed how can use daily deaths from RIP.ie to get up to date mortality estimates in Ireland. This is a useful alternative to official GRO data which lag behind by some months. It is possible to determine sex from the death notices but not age. To summarise, RIP.ie data shows unusually high mortality for 2021/22 which continues to the present (September 2022). Below is an updated plot showing how 2022 values are still trending higher....

Read more...

Mapping the historical development of Tallaght

13 August 2022

Tallaght is large surburb of Dublin about 13 km southwest of Dublin city, near the foothills of the Wicklow Mountains. Originally founded as a monastic settlement in 769 AD, it later became an important defensive outpost along the ‘Pale’ boundary. It remained a rural village until the 1960s when the Irish government commissioned town planner Myles Wright to devise an expansion plan for Dublin City. The Myles Wright Plan which was broadly adopted resulted in the creation of the three...

Read more...

Plotting gridded quantitative data with geopandas - Irish forestry

07 August 2022

A previous post showed how to create grids over polygons using geopandas. To make practical use of this requires you have some kind of quantitative data that you want to bin into each grid polygon. This could be a summary statistic over that area derived from a more fine grained spatial dataset. To do this we would combine the grid with the original data using sjoin and then aggregate using dissolve with some defined aggregating function. sjoin is like merging...

Read more...

Make regular grids from polygons with geopandas

04 August 2022

Geopandas is a Python package that provides a geospatial extension to pandas. Geodataframes store geographic data such as points and polygons which can be plotted. This post adapts code from both James Brennans and Sabrina Chans blogs to show how to make square and hexagonal grids out of any polygons. This method is often used to bin areas in discrete regions for the purpose of representing summary statistics. The functions are given below. Both uses the total boundary area and...

Read more...

All posts