Skip to content

Instantly share code, notes, and snippets.

@ian29
ian29 / import-geonames.sh
Last active July 11, 2018 10:00
downloads, cleans and imports geonames to a postgres database. essentially an automated version of this: https://github.com/colemanm/gazetteer/blob/master/docs/geonames_postgis_import.md
#!/bin/bash
set -e -u
# Download and unzip data
wget http://download.geonames.org/export/dump/allCountries.zip
wget http://download.geonames.org/export/dump/alternateNames.zip
wget http://download.geonames.org/export/dump/countryInfo.txt
unzip allCountries.zip
unzip alternateNames.zip
@ian29
ian29 / osm-style-improvements.md
Last active December 18, 2015 07:59
a list @systemed and i came up with

Mapnik style improvements

labels

  • label colors associated with features
  • for admin boundaries &c. - don't show a label if we're not rendering the actual boundary
  • nicer font - plenty of free/open options with decent glyph coverage

landuse

@ian29
ian29 / coords2meters.sh
Created April 26, 2013 17:37
convert a lat lon pair to google mercator meters
function coords2meters() {
psql -d osm -c "select st_astext(st_transform(st_geomfromtext('POINT($1 $2)', 4326) ,3857));"
}
-- from http://www.spatialdbadvisor.com/postgis_tips_tricks/92/filtering-rings-in-polygon-postgis
CREATE OR REPLACE FUNCTION filter_rings(geometry, DOUBLE PRECISION)
RETURNS geometry AS
$BODY$
SELECT ST_BuildArea(ST_Collect(b.final_geom)) AS filtered_geom
FROM (SELECT ST_MakePolygon((/* Get outer ring of polygon */
SELECT ST_ExteriorRing(a.the_geom) AS outer_ring /* ie the outer ring */
), ARRAY(/* Get all inner rings > a particular area */
SELECT ST_ExteriorRing(b.geom) AS inner_ring
@ian29
ian29 / legend.html
Last active December 12, 2015 01:38
<div class='legend-title'>American Red Cross Funded Disaster Respones:</div>
<div class="countries">
<span class='swatch'></span>
<span class="label">Countries Recieving American Red Cross Funds/span>
</div>
<style type="text/css">
.swatch {
background:#f12a2a;
height: 16px;
width: 16px;
ls foo.* | awk '{print("mv " $1" "$1)}' | sed 's/foo/bar/2' | /bin/sh
# create and populate data dir
mkdir -p data/
mkdir -p data/world_boundaries
mkdir -p data/shoreline_300
mkdir -p data/ne_110m_admin_0_boundary_lines_land
mkdir -p data/ne_10m_populated_places
mkdir -p data/processed_p

to: osm-talk,imports, talk-ha, talk-do, others?
subject: manual LSIB import to repair redaction damage.

Hi,

I've noticed that international borders all over Central America and the Caribbean were damaged by the redaction[1]. I'm proposing a limited, manual import of USAID's LSIB data[2]. Data is owned and maintained by the US Federral Gov't so it is public domain (and many of existing borders look like they were originally imported from US Census Bureau or CIA data)

Though I haven't written it yet, the ogr2osm translation funciton would probably only include admin_level= and boundary=administrative tags - there's no other relevant attributes in the source data. Once in josm I plan on manually copying the way segments from the import layer into an active editing layer and manually connect imported segments to exising ways + include them in the relevant relations I've included a sample osm file here[3] that you can rview. Let me know what you think about the import and what i'm missing. thanks,

[1]:

count uid
Rub21 37338
ngt 11291
rw_ 9511
BFX 7619
Pecisk 6485
ij_ 5893
friedl 5659
SimonPoole 4983

Mapbox streets QA

problem where z level(s) sktich comments status
orphan/ambiguous dots errywhere 4 [dots][dots] better, not fully fixed. There is no way to really solve this right now - the best we can do is make sure the scalerank densities work well at each zoom level so we're not tring to label much more than can fit on the map
island abbreviations at zoom 4 seychelles, sao tome, cabo verde 4 [sc][1] // [cv][2] // [comparison][3] - slightly more consistent now, not a big deal
triple names belgium 4-5 [belgium][4] reflects local languages wontfix
act ibt overlapping australia 4 [australia][5] - done!
low scalerank labels too black? - - - looks too much like google, departs from mb streets aesthetic done!
city labeling iceland > 8 [iceland zoom 7][8] // [comparison zoom 6][9] iceland has no cities except capital until zoom 8 << i think this is ok, just not a lot of big cities in iceland, altho it wo