From charlesreid1

No edit summary
No edit summary
Line 1: Line 1:
=Shapefiles=
=3D Map Project=


Ultimate goal: http://setosa.io/blog/2014/08/10/woodcut-data-visualization/
Ultimate goal: http://setosa.io/blog/2014/08/10/woodcut-data-visualization/


==Getting Shapefile Data==
Start from Shapefiles. Use ogr2ogr (a utility that comes with GDAL) to convert Shapefiles to GeoJSON.
 
Use D3 to pick a projection and convert GeoJSON latitude/longitude to vector (x,y) and SVG format.
 
 
 
==What You'll Need==
 
You will need a few different pieces of software for each step. These are covered below.
 
===GDAL===
 
To convert Shapefiles into GeoJSON format, you can use a utility called ogr2ogr, which is installed along with the GDAL framework.
 
On a Mac, the simplest way to install this is not to download and install a dozen packages from the internet, but rather,
 
<pre>
brew install gdal
</pre>
 
===D3===
 
The D3 (data driven documents) software library is a Javascript library that can be used to draw maps and do projections. It has software built in to do a mapping of (latitude, longitude) to (x, y).
 
https://d3js.org/
 
This is pretty straightforward to use: since it's Javascript it can be used on an HTML page.
 
You don't have to install anything, you just include the D3 library from your Javascript code, and you have everything at the ready.
 
==Shapefiles==
 
===Getting Shapefile Data===


To download elevation data in shapefile format:
To download elevation data in shapefile format:
Line 15: Line 47:
Download the shapefile data and unzip it
Download the shapefile data and unzip it


==Shapefiles to GeoJSON==
===Shapefiles to GeoJSON===


We'll convert these shapefiles to something better for the web: GeoJSON
We'll convert these shapefiles to something better for the web: GeoJSON
Line 32: Line 64:
ogr2ogr -f GeoJSON -t_srs crs:84 Elev_Contour.geojson Elev_Contour.shp
ogr2ogr -f GeoJSON -t_srs crs:84 Elev_Contour.geojson Elev_Contour.shp
</pre>
</pre>
=Flags=




[[Category:July 2016]]
[[Category:July 2016]]

Revision as of 19:48, 28 July 2016

3D Map Project

Ultimate goal: http://setosa.io/blog/2014/08/10/woodcut-data-visualization/

Start from Shapefiles. Use ogr2ogr (a utility that comes with GDAL) to convert Shapefiles to GeoJSON.

Use D3 to pick a projection and convert GeoJSON latitude/longitude to vector (x,y) and SVG format.


What You'll Need

You will need a few different pieces of software for each step. These are covered below.

GDAL

To convert Shapefiles into GeoJSON format, you can use a utility called ogr2ogr, which is installed along with the GDAL framework.

On a Mac, the simplest way to install this is not to download and install a dozen packages from the internet, but rather,

brew install gdal

D3

The D3 (data driven documents) software library is a Javascript library that can be used to draw maps and do projections. It has software built in to do a mapping of (latitude, longitude) to (x, y).

https://d3js.org/

This is pretty straightforward to use: since it's Javascript it can be used on an HTML page.

You don't have to install anything, you just include the D3 library from your Javascript code, and you have everything at the ready.

Shapefiles

Getting Shapefile Data

To download elevation data in shapefile format:

Zoom into the area you want

Check "US Topo" and click Find Products

Next to each item, there are four links - the third one is "Download"

Download the shapefile data and unzip it

Shapefiles to GeoJSON

We'll convert these shapefiles to something better for the web: GeoJSON

See http://ben.balter.com/2013/06/26/how-to-convert-shapefiles-to-geojson-for-use-on-github/

Install homebrew, then:

brew install gdal

This will install a utility called ogr2ogr, which we'll use to convert shapefiles to GeoJSON files.

ogr2ogr -f GeoJSON -t_srs crs:84 Elev_Contour.geojson Elev_Contour.shp


Flags