Skip to content

Commit

Permalink
Reduce population density false positives
Browse files Browse the repository at this point in the history
  • Loading branch information
ansoncfit committed Aug 29, 2023
1 parent 5550a15 commit bb50f3f
Show file tree
Hide file tree
Showing 3 changed files with 587 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ public SuspectStopLocationError(String stopId, long line) {

@Override public String getMessage() {
return String.format(
"Stop with ID %s is located in a 1/4 degree cell with less than 5 inhabitants per square km.",
"Stop with ID %s is in a sparsely populated area (fewer than 5 inhabitants per square km in any " +
"neighboring 1/4 degree cell)",
affectedEntityId
);
}
Expand Down
11 changes: 7 additions & 4 deletions src/main/java/com/conveyal/gtfs/storage/BooleanAsciiGrid.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,22 @@ public BooleanAsciiGrid (InputStream inputStream, boolean gzipped) {
}

/**
* Get a grid for places where population density is over 5 people per square kilometer.
* Get a grid for places where population density is over 5 people per square kilometer in any neighboring cell.
* We use the Gridded Population of the World v3 data set for 2015 UN-adjusted population density.
* This data set was downloaded at 1/4 degree resolution in ESRI ASCII grid format. The grid file was edited
* manually to eliminate the no-data value header, since I could not find a way to operate on no-value cells in the
* QGIS raster calculator. Then the raster calculator in QGIS was used with the formula ("glds00ag15@1" > 5),
* which makes all cells with population density above the threshold have a value of one,
* and all others a value of zero (since the no data value in the grid is -9999). This was then exported as another
* ASCII grid file, which zips well. The license for this data set is Creative Commons Attribution.
* and all others a value of zero (since the no data value in the grid is -9999). Next, the GRASS r.neighbors tool
* in QGIS was used to blur this layer, adding to each cell the sum of the neighboring eight cells ("neighborhood
* size" of 3, apparently the dimension in each direction). A final logical operation ("blurred@1" > 0) was
* applied, with the result exported as another ASCII grid file, which zips well. The license for this data set
* is Creative Commons Attribution.
* See http://sedac.ciesin.columbia.edu/data/collection/gpw-v3
*/
public static BooleanAsciiGrid forEarthPopulation() {
try {
InputStream gridStream = BooleanAsciiGrid.class.getResourceAsStream("gpwv3-quarter-boolean.asc");
InputStream gridStream = BooleanAsciiGrid.class.getResourceAsStream("gpwv3-quarter-buffer-boolean.asc");
return new BooleanAsciiGrid(gridStream, false);
} catch (Exception ex) {
throw new RuntimeException(ex);
Expand Down
Loading

0 comments on commit bb50f3f

Please sign in to comment.