Skip to content

Instantly share code, notes, and snippets.

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]:

# 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
ls foo.* | awk '{print("mv " $1" "$1)}' | sed 's/foo/bar/2' | /bin/sh
@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;
-- 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 / 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));"
}
@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 / 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 / macpg.sh
Last active December 21, 2015 22:49
easiest way to install postgres (and postgis) on mac os x
# !/bin/bash
# make sure homebrew is up-to-date and install some stuff
brew update
brew install postgres || brew upgrade postgres
brew install postgis || brew upgrade postgis
# if you dont have brew on your path yet
echo "export PATH=/usr/local/bin:$PATH" >> ~/.bash_profile
source ~/.bash_profile
@ian29
ian29 / gist:6694803
Last active December 23, 2015 21:09
create table test2 (
gid int,
qs_adm0 text
);
SELECT AddGeometryColumn('public', 'test2', 'geom', 4326, 'MULTIPOLYGON', 2);
insert into test2 (
SELECT
gid,
qs_adm0,