<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Blog | Ina Krapp</title><link>https://inakrapp.github.io/post/</link><atom:link href="https://inakrapp.github.io/post/index.xml" rel="self" type="application/rss+xml"/><description>Blog</description><generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>en-us</language><lastBuildDate>Tue, 10 Mar 2026 00:00:00 +0000</lastBuildDate><image><url>https://inakrapp.github.io/media/icon_hu7729264130191091259.png</url><title>Blog</title><link>https://inakrapp.github.io/post/</link></image><item><title>sfcentralities: Calculating centralities from sf objects</title><link>https://inakrapp.github.io/post/sfcentralities/</link><pubDate>Tue, 10 Mar 2026 00:00:00 +0000</pubDate><guid>https://inakrapp.github.io/post/sfcentralities/</guid><description>&lt;p>While I generally like to work with the &lt;code>sf&lt;/code> library in R, it is unfortunate that the R ecosystem when it comes to spatial data is quite heterogeneous: Available spatial formats do not only include vector and raster data, but the structures in which they are stored are also usually heavily influenced by the design choices of authors of certain packages:&lt;/p>
&lt;ol>
&lt;li>
, probably the first widely used spatial package in R - at least, it is among the older ones, and
, which is often treated as its successor.&lt;/li>
&lt;li>
, a package by the authors of &amp;ldquo;Spatial Point Patterns: Methodology and Applications with R&amp;rdquo;&lt;/li>
&lt;li>
is more often used for raster data, but also has capabilities to handle vector data, and is, in many ways, a successor to the
package&lt;/li>
&lt;/ol>
&lt;p>&amp;hellip;and then there is the option to store coordinates in an ordinary R dataframe with columns named &amp;lsquo;Longitude&amp;rsquo; and &amp;lsquo;Latitude&amp;rsquo; or &amp;lsquo;X&amp;rsquo; and &amp;lsquo;Y&amp;rsquo; and ignore spatial packages entirely.&lt;/p>
&lt;p>These are just the packages and ways to work with spatial data I encountered most frequently. And spatio-temporal analysis is also growing more common (anyone interested in this field: I highly recommend taking a look at the
package).&lt;/p>
&lt;p>I think it is an unfortunate situation for beginners who aim to perform spatial analysis in R. Even if you have some experience, especially if it is in one package, working with another package can feel like starting from zero again. Many authors have valid reasons for their design choices, and there is a growing awareness of the issue; many packages also contain functions to transform data from one format to the other. But sometimes, I find functions implemented in packages that do not see themselves as &amp;lsquo;spatial&amp;rsquo; to begin with.&lt;/p>
&lt;p>For example, when I tried to find out how to calculate the geometric median in R, the R package that appeared first in the search results was
- Practical Numerical Math Functions. The package is impressive for the breadth of functions it covers, but this result also shows how different the contexts are in which functions are used. The geometric median can be used by geographers to find a central point on the map, but is also used, for example, in principal component analysis - which is an entirely different story. There are even more packages in R which offer functions for the calculation of geometric medians -
, for example, which is particularly optimized for high-dimensional, large datasets and very fast due to its reliance on C++. So many users of the geometric median do not analyse spatial data.&lt;/p>
&lt;p>But I did, for a project, and this is a part of where
(more precisely: the function &lt;code>st_geo_median&lt;/code>) comes from. It takes &lt;code>sf&lt;/code> objects as input, it gives &lt;code>sf&lt;/code> objects as output, it is not reinventing the wheel, but beginner-friendly and easy to use - at least I hope so. But it is not entirely a package purely written with convenience in mind: Since spatial data can be in projected or geographic coordinates, using purely-number based implementations like &lt;code>pracma&lt;/code> or &lt;code>Gmedian&lt;/code>, which can not properly handle longitude and latitude values can give wrong results - &lt;code>sfcentralities&lt;/code> will give an error if the user attempts it.&lt;/p>
&lt;p>Why can other packages give wrong results? Because distances in the longitude-latitude-system are not constant: One degree corresponds to a different distance in meters depending on if you are at the equator or at the poles. So, despite the sometimes complex implementations of these packages, there are good reasons to use spatial packages for spatial data.&lt;/p>
&lt;p>&lt;code>sfcentralities&lt;/code> is also a bit of an attempt to bridge the gap between &lt;code>sf&lt;/code> and the
package. &lt;code>dodgr&lt;/code> is one of the packages that just show how powerful R can be. &lt;code>dodgr&lt;/code> stands for &amp;lsquo;Distances on Directed Graphs&amp;rsquo;, and while it can take &lt;code>sf&lt;/code> objects as input and even offers a function to download data from OpenStreetMap in &lt;code>sf&lt;/code> format to use for analysis, it also heavily builds on its own data format,
. It allows very fast and precise distance and time calculations even in complex street networks, since it is able to take into account different modes of transport, one-way streets and other factors that go beyond a simple &amp;lsquo;distance in kilometers/miles&amp;rsquo; measure.&lt;/p>
&lt;p>I have been using it to calculate a similar measure to the geometric median - a measure which minimizes the sum of distances to points - along a street network. This is not really equivalent to the geometric median because it does not necessarily fulfill a global optimality condition - I can say that the geometric median is the point which minimizes the sum of distances to all points in a set since the geometric median is calculated using Euclidean (straight-line) distances. For a network distance, I can only say that a certain point I evaluated has a higher closeness than other points I evaluated. This is the closeness centrality, and in &lt;code>sfcentralities&lt;/code>, it is implemented in the function &lt;code>st_closeness_centrality&lt;/code>.&lt;/p></description></item><item><title>Wisp: A locally running version of Whisper</title><link>https://inakrapp.github.io/post/wisp/</link><pubDate>Sat, 13 Apr 2024 00:00:00 +0000</pubDate><guid>https://inakrapp.github.io/post/wisp/</guid><description>&lt;p>Whisper is a transcription software that allows to turn audio files into text. I created a
locally running version of it, Wisp, with the aim to give it a simple, intutive user interface. My project can be found here:
&lt;/p>
&lt;p>Whisper itself has been developed by OpenAI, which is also the company behind ChatGPT and several other Artificial Intelligence programs.
You can try it out here: ‚
‘.&lt;/p>
&lt;p>Unlike ChatGPT, Whisper does not have a user interface designed by OpenAI. Its demos, as you might have seen if you tried it out above, often are used by many people at the same time. Since they all send their requests to the same computer, people may have to wait a very long time before they receive the text. Alternatively, Whisper can be run locally, using Python, but for anyone who does not know how to use a programming language, this is not an option.&lt;/p>
&lt;p>So the aim of my project was to make Whisper easy to use for anyone, on their own computer.&lt;/p>
&lt;p>Wisp is supposed to run without internet connection. Any user runs it on their computer, meaning that the users won‘t have to wait before the program finished the text of someone else. Since it has a graphical user interface, it is easy to use for anyone who is familiar with standard office software like Microsoft Office.&lt;/p>
&lt;p>Like with many of my other projects, I learnt a lot in the process of building this program. Before I started, I had no experience in working with audio data and very little with building a graphical user interface in Python. It was also my first time I turned a Python program into an executable windows program.&lt;/p></description></item><item><title>An ARIMA model of the global average temperature</title><link>https://inakrapp.github.io/post/arima/</link><pubDate>Sat, 12 Aug 2023 00:00:00 +0000</pubDate><guid>https://inakrapp.github.io/post/arima/</guid><description>&lt;p>I wrote an ARIMA model to predict the average global temperature.&lt;/p>
&lt;p>I would not call it a climate model because it only covers one of the many aspects of the climate. Of course, it is much more limited compared to those developed by experts in the field. Still, writing it taught me a lot about forecasting of time series.&lt;/p>
&lt;p>Today, I would do some things different. In particular, I probably would discourage people who use ARIMA models from interpolating missing data points.
The ARIMA model can still be used when some data is missing. I used interpolation originally because I also experimented with ETS models, who require a time series without gaps. But the ETS model is not in the published version of the code because its predictions were not very good.&lt;/p>
&lt;p>The code (with extensive commentary) can be downloaded
. It is written in a quarto document and should run on any relatively recent version of R and Rstudio.
The &amp;lsquo;Global_Temperature.txt&amp;rsquo; and &amp;lsquo;merged_ice_core_yearly.csv&amp;rsquo; files contain the data the model uses, so they have to be downloaded into the same folder as well to run the code.
For anyone who just wants to take a look at the results and doesn‘t want to run or modify the code themselves, here is the
.&lt;/p>
&lt;p>Edit from October 19th 2023: I uploaded a version that can be used for Workshops in Germany. It is in the subfolder &amp;lsquo;Workshop&amp;rsquo;.&lt;/p></description></item></channel></rss>