https://gist.github.com/tomay/8657441
Mapshaper.org is a powerful tool to convert .shp to geojson/topojson and viceversa. Some of other mapshaper.org features are:
- Simplify geometry in order to reduce the file size
- Filter and rename geometry properties
- Map Data in .shp and its companion file (.shx and .dbf)
N.B:
- .shx and .dbf file are important. It contains the properties of each area like the area name, etc.
- If the map data is in geojson or topojson file then you must convert it first to a shapefile using mapshaper.org.
- Put your .shp and its companion file (.shx and .dbf) within the same folder
- Move/copy them to a temporary folder in /etc/myfolder (You can delete this folder later after finished)
- Login as postgres user using
sudo su - postgres
command - Type command
shp2pgsql -s 900913:4326 /etc/myfolder/SHAPEFILE_NAME.shp SCHEMA.TABLE | psql -h HOSTNAME -d DATABASE_NAME -U USER
- Done
N.B:
- In order to be displayed properly map data need to be projected in mercator projection (SRID 4326). So make sure your shapefile is projected in mercator.
- If not then you can project it to mercator by using the specified
shp2pgsql
command above (highlight the parameter900913:4326
) where900913
is the origin SRID and4326
is the targeted SRID.- Take a look at this cheatsheet to understand more about the paramater in
shp2pgsql
.
- Login as postgres user using
sudo su - postgres
command - Type
psql
command to enter the postgresql sql mode - Type
\c db_name_where_data_inserted
to connect to the DB - Type
select * FROM SCHEMA.TABLE LIMIT 1
to view the DB content - If you able to see a record then it has been inserted successfully (Sometime you can only see the header due to console mode limitation)
- To start tilestache type
tilestache-server.py -c /Path/to/configfile.cfg
in the console - Last time I put the config file in
/etc/TileStache/tilestache.cfg
- You can read the explanation about the config file in the tilestache documentation
- Indonesia Level 2 Administrative (another country data also available)
- Indonesia Level 3 Administrative
- Indonesia Level 3 Administrative Per Island (lack of sumatra island)