|
1 |
| -infoamazonia-maps |
2 |
| -================= |
| 1 | +# TileMill Projects |
3 | 2 |
|
4 |
| -Tilemill map project made for Infoamazonia |
| 3 | +Most TileMill projects for the maps on infoamazonia site live in `/oeco-amazonia/maps-src/tilemill/`. Exceptions include |
| 4 | + |
| 5 | +- forest-height map |
| 6 | +- fire-frequency heatmap |
| 7 | +- osm roads and labels |
| 8 | + |
| 9 | +OSM borders + labels were left out due to the complex nature of the project, and the unlikely event that the border or labels will need to be frequently updated. |
| 10 | + |
| 11 | + |
| 12 | +## Install |
| 13 | + |
| 14 | +You can either copy each of the projects in this directory to TileMill project directory (default: `~/Documents/Mapbox/project`), or you can create [symlinks](http://en.wikipedia.org/wiki/Symbolic_link) to the projects as they exist in the GitHub repo. For example |
| 15 | + |
| 16 | + ln -s ~/path-to/oeco-amazonia/maps-src/tilemill/deforestation ~/Documents/Mapbox/project/deforestation |
| 17 | + |
| 18 | +This will let you use git to track changes made in TileMill. |
| 19 | + |
| 20 | +An effort has been made to point all non-postgres layers at directories in the dropbox, minimizing set up time. You can move data layers into git-tracked directories but be sure to use 'git checkout' to make sure they're not pushed to the GitHub repo - this will needlessly slow down everyone's pulls, especially as this data already exists in the dropbox. |
| 21 | + |
| 22 | +Many layers are powered by a postgis database that allows reformatting of dates, area numbers, etc. To set up this data base run from your command (bash) shell: |
| 23 | + |
| 24 | + createdb amazonia |
| 25 | + psql -d amazonia -c "CREATE EXTENSION postgis" |
| 26 | + |
| 27 | +All of this data I've included in a database dump calle 'desmata.sql'. A zipped version can be found in the dropbox here: |
| 28 | + |
| 29 | + ~Dropbox/InfoAmazonia_data/1_environmentalLayers/deforestation/amazonia.dump.zip |
| 30 | + |
| 31 | +Run this command to populate the database |
| 32 | + |
| 33 | + psql -d amazonia -f amazonia.dump |
| 34 | + |
| 35 | +NOTE: this assumes you are running postgis2.0 |
| 36 | + |
| 37 | +## Deforestation |
| 38 | + |
| 39 | +Historical deforestation is powered by the 'desm91' shapefile that lives here: |
| 40 | + |
| 41 | + ~/Dropbox/InfoAmazonia_data/1_environmentalLayers/deforestation/IBGE/deforestation_1991_shp/desm91.shp |
| 42 | + |
| 43 | +More recent deforestation is powered by the postgis database, for the above reasons but also so that 'last3months' table retrieves the last 3 months of deforestation data, regardless of when the last import of data was. The desmata.sql database dump includes data from jan 2005 to mar 2012. |
| 44 | + |
| 45 | +You should now be able to open the project in TileMill. |
| 46 | + |
| 47 | +### Updating deforestation |
| 48 | + |
| 49 | +To update the table, download and reproject the latest DETER update: |
| 50 | + |
| 51 | + ogr2ogr -s_srs EPSG:4291 -t_srs EPSG:900913 deter_june2012.shp deter_201206.shp |
| 52 | + |
| 53 | +Now you can run the following command from you bash shell (this example will import the DETER data from march 2012): |
| 54 | + |
| 55 | + shp2pgsql -D -a deter_june2012.shp desmata | psql -d amazonia |
| 56 | + |
| 57 | +NOTE: Be sure to include the `-a` option, as this will _append_ the monthly data rather than overwrite the existing table with the update! |
| 58 | + |
| 59 | +Once the import is complete you will need to update and optimize the tables in your database. Run the following command included in `maps-src`. |
| 60 | + |
| 61 | + psql -d amazonia -f desmata-update.sql |
| 62 | + |
| 63 | +## Fires |
| 64 | + |
| 65 | +These projects are also is being powered by the postgres database. They are broken out into separate projects so preserve interactivity for both the high-intensity (yellow) layer, and the recent fires layer (red). Data for both these layer has been included in the desmata.sql dump. |
| 66 | + |
| 67 | +### Updating Fires |
| 68 | + |
| 69 | +You can now import it with shp2pgsql. Again, note the `-a` flag that appends this data to the fires table rather than overwriting the existing table. Read more about shp2pgsql [here](http://www.bostongis.com/pgsql2shp_shp2pgsql_quickguide_20.bqg). |
| 70 | + |
| 71 | + shp2pgsql -D -a july-merc.shp fires | psql -d amazonia |
| 72 | + |
| 73 | +Before your changes will take a effect you will need to the `update-fires.sql` script: |
| 74 | + |
| 75 | + psql -d amazonia -f update-fires.sql |
| 76 | + |
| 77 | +After importing the FIRMS data, and running the update-fires.sql script, tilemill project for both high-intensity fires and recent fires should work. |
| 78 | + |
| 79 | +__OPTIONAL:__ To load historical data yourself [re-projecting](http://mapbox.com/tilemill/docs/guides/optimizing-shapefiles/) your NASA shapefile to Google Mercator you will need to upload it with shp2pgsql. Be sure to call the table 'fires' as in the import command below: |
| 80 | + |
| 81 | + shp2pgsql -D -a firms1961337193914.shp fires| psql -d amazonia |
| 82 | + |
| 83 | +again, run the optimization script in `/maps-src`. |
| 84 | + |
| 85 | + psql -d amazonia -f update-fires.sql |
| 86 | + |
| 87 | + |
| 88 | +## Mining (and protected areas) |
| 89 | + |
| 90 | +- After installing you will need to move the `mining.zip` file that exists at `~/Dropbox/InfoAmazonia_data/1_environmentalLayers/` to `oeco-amazonia/maps-src/tilemill/mining/layers/` and then unzip it. |
| 91 | +- to regenerate the map, you will need an older developer build (some of the features this map uses have been in rapid development). specifically you'll need [Tilemill v0.9.1.6x](https://github.com/downloads/mapbox/tilemill/TileMill-0.9.1.66-compositing-preview.zip) version. |
| 92 | +- the project should now work. be careful not to commit the data layers, as they will weight down the repo. |
| 93 | + |
| 94 | +# Legends + Tooltips |
| 95 | + |
| 96 | +Legends should already be saved in TileMill projects, but have also been saved as an html file at `oeco-amazonia/maps-src/legends-src.html`. The same is true of tooltips, which live at `oeco-amazonia/maps-src/tooltip-src.html` |
0 commit comments