Posts

Showing posts from 2017

Beverton–Holt: a discrete-time logistic model

The Beverton–Holt equation is a recurrence relation relating abundance of a population in generation $n$ to the abundance of the previous generation $n - 1$: $N_n = \frac{PN_{n-1}}{1 + PC^{-1}N_{n-1}},$ where $N_n$ is the abundance at generation $n$, $P$ is the density-independent productivity of the population, and $C$ is the capacity of the population. This recurrence relation can be solved to explicitly relate the abundance at generation $n$ with the initial abundance $N_0$. Let $Q$ be the equilibrium abundance of the population given by the equation $Q = C \left (1-P^{-1} \right).$ Using this definition, the abunance at generation $n$ is given by the equation $N_n = \frac{QN_0}{N_0 + P^{-n}\left (Q - N_0 \right )}.$ The standard Beverton–Holt recurrence relation has an alternative form that is very similar to the solution of the recurrence relation. \begin{align} N_{n} &= \frac{P N_{n-1}}{1 + P C^{-1} N_{n-1}} \\ &= \frac{P N_{n-1}}{1 + P \left (1 - P^{-1 }

Angular Carto: Compound basemaps

This post is part of a series covering how to create reusable Carto map components. Read the introduction to learn why one would even want to do such a thing. The previous post in the series was voluminous, so I will change things up and describe a minor enhancement to basemap switching : basemaps that consist of more than one tile layer. This is particularly useful for adding labels to a basemap. Enhancing the basemap prototype This post builds off of the previous post on basemap selection. I will describe how specific components will change to accommodate multiple tile layers in a basemap. You may find it helpful to read the previous post to understand how the other components work. First, consider the basemap prototype that requires exactly one tile layer. Its public interface exposes addToMap() and removeFromMap() methods. Accommodating multiple tile layers in the basemap is as simple as adding a for loop to both methods. Note that after each tile layer is added to the m

Angular Carto: Switching Basemaps

This post is part of a series covering how to create reusable Carto map components. Read the introduction to learn why one would even want to do such a thing. In this post, we will discuss how to give the user control of the basemap and how to do some customizations on the basemap selector. Manipulating the basemap Before we begin, we need to ask ourselves: what is a basemap, and what does it do? In the context of a Carto map, a basemap is a layer of map tiles that sits under the informational layers. In order to be able to switch between different basemaps, each basemap should know how to add itself to the Carto map and how to remove itself from the Carto map. This functionality is implemented in the basemap prototype, cleverly named basemapProto . The prototype has two properties and two methods: tileLayer The Leaflet tile layer for the basemap. map The Carto/Leaflet map whose basemap is to be manipulated. addToMap() Add the basemap to the Carto/Leaflet map object. remove

Angular Carto: Custom Zoom Buttons

This is part of a series covering how to create reusable Carto map components. Read the introduction to learn why one would even want to do such a thing. Read the previous installment, Carto Map Factory , to learn about adding a Carto map to a webpage and registering the map with the Angular dependency injector. In this post, we will discuss how to add custom zoom buttons to the map. What are directives? We will implement our custom zoom buttons by encapsulating them in an Angular directive. Directives are a technique for packaging up bundles of HTML content and JavaScript code. Once a directive has been registered in your Angular module, it can be interpolated into the HTML of your web page, most commonly as an HTML element or as an attribute on a standard element. A good use case for directives is a text field with a date picker. The date picker should pop up a window with a navigable calendar, allow the user to browse through the calendar to find the date they want, and then sa

Angular Carto: Map Factory

This is part of a series covering how to create reusable Carto map components. Read the introduction to learn why one would even want to do such a thing. In this post, we will discuss how to add a Carto map to a website and how to register the map with Angular so that our Angular components can manipulate the map display. Reference the scripts Before jumping into your new Carto map, you will first need to make sure that your web page has references to the Carto and Angular javascript libraries. In order for the map to tile correctly, you will also have to reference Carto’s standard stylesheet. Sizing web page and containers If you’re looking for an immersive map that takes up the entire web page, you will need to make sure that the html and body elements and the map container are all styled to fill all space available to them. My preferred method is to define a site-wide style implementing those requirements, including a carto-map-container CSS class that can be applied to

Angular Carto: Introduction

If you work with geospatial data and haven't had a chance to work with Carto , you are missing out. Carto is a platform for creating interactive geospatial visualizations on the web. The canned maps that you can build from the web-based designer are surprisingly powerful, especially if you are already familiar with SQL and CSS . If you are a proficient web programmer, you can use their JavaScript API to customize your map in virtually any way you can imagine. Carto hits a sweet spot of simplicity and flexibility that suits me nicely. I work on a team whose job is to help our clients make sense of data. The efficiency with which we can produce Carto web applications frees up our time to add value in other areas. As great as Carto is, one problem that is becoming more pressing is that we're making a lot of the same maps on different data sets. Consequently, we're starting to do a lot of copy-and-paste code reuse . Over the next year, we will be refactoring essential map f