d3: us states in topojson format filesize is way too large

核能气质少年 提交于 2019-12-03 04:02:01

In addition to rysloan suggestions you can use Mapshaper and QGIS to extract the state boundaries. Both of these are also free. To get just the us-states follows these steps:

  • Upload the us.json file to Mapshaper;
  • Export it as a shape file;
  • Unpack the zip and you'll notice the Mapshaper has already split your topojson into 3 shape files one of which is us-states;
  • Upload the us-states.shp and us-states.shx to Mapshaper (you'll have to refresh Mapshaper to get rid of the orginal us.json file first); and
  • Save as topojson and you'll have a file 58kb in size.

if your states json file still contains:

objects:{"counties..." 

then you still have county borders in your file. you will need to do some pre-processing on your file before using it. you might be able to just remove the 'counties' property using javascript (underscore is a good library for object manipulation, see _.omit). other options involve using some gis to dissolve the county polygons. PostGIS and R would be two ways to do this for free(see ST_UNION in postgis or unionSpatialPolygons in R's maptools library).

as far as making the world borders map smaller, I am not too sure. looks like its pretty bare bones as is.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!