Skip to content

Instantly share code, notes, and snippets.

@mfurlend
Last active November 21, 2016 02:20
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mfurlend/9dc2029ee0d16fa418bd95df83c6168c to your computer and use it in GitHub Desktop.
Save mfurlend/9dc2029ee0d16fa418bd95df83c6168c to your computer and use it in GitHub Desktop.

###export bounding box for reuse export LON1=-74.259094 export LAT1=40.477398 export LON2=-73.700165 export LAT2=40.91758

###mapbbox.js outputs a .png image using the Web Mercator (EPSG: 3857) projection

./mapbbox.js -h 480 -w 640 \                           #dimensions of output image (px)
-b $LON1,$LAT1,$LON2,$LAT2 \                           #bounds: lon1,lat1,lon2,lat2
-o NYC.png

img alt="NYC.png" ##gdal_translate georeferences the .png image by creating a GeoTIFF

gdal_translate -of Gtiff -co tfw=yes \                 #output geotif file along with tfw (world file)
-a_ullr $LON1 $LAT2 $LON2 $LAT1 \                      #bounds: upper left, lower right
-a_srs EPSG:3857 \                                     #source projection
NYC.png NYC.3857.tif                                   #src dst

##gdalwarp reprojects the georeferenced tiff to World Equidistant Cylindrical (EPSG: 32663*) gdalwarp -t_srs EPSG:32663 \ #target projection NYC.3857.tif NYC.32663.tif #src dst

img alt="NYC.3857.tif"

These two images are not identical. Overlaying the source image with the destination demonstrates that the image was reprojected. img alt="NYC-overlayed.tif"

######*see also http://spatialreference.org/ref/epsg/wgs-84-plate-carree/ notes:

EPSG Common Name(s) Description
4326 Plate Carre (Geographic) NOT yet transformed to a projection. Uses a coordinate system the same as a GLOBE (curved surface).
3857 Web Mercator Uses a coordinate system the same as a MAP (flat surface).
900913 Web Mercator Identical to EPSG 3857. Deprecated.

Leaflet.js wants non-projected (EPSG 4326) GeoJSON. Leaflet does the projection to Web Mercator for you.

Web mercator NOT == spherical mercator google mercator == Web Mercator (Auxiliary Sphere)

Loading data to Mapbox Studio/TileMill has to be in WGS 84, Mercator EPSG:4326 Once those data gets uploaded, it converts into EPSG:3857 WebMercator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment