d3.js - shp2json produces GeoJSON with bounding and coordinates not in (-180,180) range -
i doing @mbostock's tutorial on command line cartography 1. here i've done:
1) download zip file
wget https://www.arb.ca.gov/ei/gislib/gislib.htm/ca_air_basins.zip
(from california air resources board site)
2) manually unzip clicking .zip
file (unzip
command did not work because downloaded file didn't have 'end-of-central-directory signature')
2) convert shapefile geojson shp2json caairbasin.shp -o ca.json
3) make geojson projection using california albers (specified in caairbasin.prj
file):
geoproject 'd3.geoconicequalarea().parallels([34, 40.5]).rotate([120, 0]).fitsize([960, 960], d)' < ca.json > ca-albers.json
result: ca-albers.json
(223m) bigger ca.json
(6.3m). in census tract shapefile used in tutorial, file size increases 10 14 m.
update: seems problem shp2json
step instead of geoproject
step. looking @ caairbasin.shp.xml,
there 2 sets of bounding,bounding
, lbounding.
in case,lbounding
, coordinate values in 100,000s range used opposed (-180, 180) in tutorial, making projection fail.
what next step - there alternative shp2json
work case? or how can translate bounding/coordinates appropriate (-180,180) ones?
thank you.
your shapefile projected. passing through d3.geoconicequalarea, projecting twice; d3.geoconicequalarea expects wgs84 (longitude , latitude in degrees) input, you’re giving projected coordinates.
you can tell shapefile projected looking @ prj file, or looking @ coordinates of geometry generated shp2json: first point [-298228.39936644124, 437516.87775637675], outside expected range of [±180°, ±90°] longitude , latitude.
rather re-projecting geometry new projection, easiest thing use projection it’s in. need translate , scale fit desired display size of 960×960. can use d3.geoidentity this.
geoproject 'd3.geoidentity().reflecty(true).fitsize([960, 960], d)' < ca.json > ca-albers.json
setting identity.reflecty fix vertical orientation of geometry: gis convention +y points up, canvas , svg convention +y points down.
Comments
Post a Comment