脆皮边缘与topojson? [英] Crispy edges with topojson?

查看:231
本文介绍了脆皮边缘与topojson?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Mike Bostock分享了一系列世界范围的topojson文件。



由于我想要更多的数据和更高的质量,我现在从自然地球生成自己的高质量topojson文件。为了简单,我的makefile /命令是这样的:

  admin_0:crop 
../node_modules/topojson/ bin / topojson \
--id-property name \
-p name = name \
-q 1e4 \
--filter = small \
-o admin_0.topo.json \
- admin_0 =。/ natural_earth_vector / 10m_cultural / ne_10m_admin_0_countries.shp

但我的 3MB 在优雅方面令人惊讶。不完美,但很好,他确实有对角线(!)和他的线使用的各种角度。





我尝试将量化减少到 -q 1e3

命令行API ,我注意到并阅读尽可能多的:




  • -q, - 量化, - 无量化沿任一维度的可微分点的最大数量

  • -s,--simplify用于Visvalingam简化的精度阈值

  • - 简化比例以保持Visvalingam简化的点数

  • - 宽度缩放并进行翻译以适合视口


$ b b p>这可能都有帮助我。我做了一些测试,主要学习了平衡简化是棘手的。我想请经验丰富的用户如何处理和平衡他们的topojson简化。



你采取什么方法?因此...
我应该使用哪些topojson参数来使我的topojson更好?(没有酥脆的楼梯 - 步骤边缘,正确的忠诚的形状)

解决方案

-q VS -s



有关 Topojson:quantization VS simplification


您的几何的总大小由两个因素控制:
的数字位数每个坐标
点数


c $ c> -q 减少每个坐标的位数。最初,地理位置具有非常高的精度,例如

  ...,[ -  90.07231180399987,29.501753271000098],[ -  90.06635619599979,29.499494248000133],... 

量化 -q 1e4 strong>其中 1e4 = 10000创建一个10,000×10,000网格,整数值介于0和9999之间,例如 [ - 6700,1030] 。根据坐标的字符从〜40减少到 12 ,减少了〜75%,最大值为 4 个数字。其次,quatization使得在输入shapefile中不同的地理点现在共享相同的坐标,例如 [24,62],[24,62],[24,62] ... 。这些重复项被合并。最终结果是由网格上的点定义的形状。 如果您只使用量化,则您的形状将采用从网格点到网格点的垂直+水平线。



简化通过删除点删除信息。 TopoJSON使用的Visvalingam方法消除了最不引人注意的点,这一原则在 Line Simplification article 。要有许多精细的三角形精细删除,首先使用更高的量化,然后简化:

  #world 
topojson -q 1e6 -s 7e-5 -o world-110m.json - NaturalEarth-110m.shp

这是通过删除一些角点在基于topojson的形状中创建对角线的简化。



-s



有关Google群组的问题,M. Bostock 提议的一些聪明的提示。



  1. 对于美国,请使用 -s 7e-7 。 e表示指数,以球面坐标的球面度测量。 7e-8 小十倍,这是更多的细节!


  2. 最近,我开始预投射TopoJSON。这允许您在屏幕像素( - cartesian --width 960 -s 1 对于一个正方形像素,例如)中指定直观的简化阈值,




演示



href =http://bl.ocks.org/mbostock/6320825 =nofollow>现场使用和其他类似的:

 #projection(从输入shapefile大时给出节点额外的内存)
us-albers.json:County_2010Census_DP1.shp
node --max_old_space_size = 8192 node_modules / .bin / topojson \
-q 1e5 \
-s 1 \
--projection'd3.geo.albersUsa()'\
--id-property = GEOID10 \
-p name = NAMELSAD10,pop = + DP0010001 \
-o $ @ \
--counties = County_2010Census_DP1.shp

#预计(本示例不使用,但包括供参考)
topojson --max_old_space_size = 8192 \
-q 1e6 \
-s 7e-5 \
- o world-110m.json \
- NaturalEarth-110m.shp
#USA
topojson \
-q 1e5 \
-s 7e-7 \
--id-property = GEOID10 \
-p name = NAMELSAD10,pop = + DP0010001 \
-o $ @ \
- counties = County_2010Census_DP1 .shp

如果未投影,则映射区域的尺寸缩小10倍内华达州), 7e-7 应移至较小的值,例如 7e-8



笛卡尔



http://bost.ocks.org/mike/simplify/


Mike Bostock shared a range of world wide topojson files.

As I wanted more data and higher quality, I now generate my own high quality topojson files from Natural Earth. To make it simple, my makefile / command is such:

admin_0: crop
    ../node_modules/topojson/bin/topojson \
        --id-property name \
        -p name=name \
        -q 1e4 \
        --filter=small \
        -o admin_0.topo.json \
        -- admin_0=./natural_earth_vector/10m_cultural/ne_10m_admin_0_countries.shp

But my 3MB .topojson is crispy, nasty, graphically messy. Take a look at the coastline, you will see the most annoying thing : lines looking like "stairs" : horizontal, vertical, horizontal, vertical,...

On his side, M. Bostock's 90kb .topojson does surprisingly fine in term of elegance. Not perfect, but nice, and he does have diagonals (!) and various angles used by his lines.

I tried reducing the quantization to -q 1e3, but it keeps crispy, and it's even more ugly: the stair's steps are even bigger.

From the command line API, I noticed and read as much as I could on :

  • -q, --quantization, --no-quantization maximum number of differentiable points along either dimension
  • -s, --simplify precision threshold for Visvalingam simplification
  • --simplify-proportion proportion of points to retain for Visvalingam simplification
  • --width scale and translate to fit a viewport of the specified width
  • --height scale and translate to fit a viewport of the specified height

which may all help me. I made some test to mainly learn that balancing simplification is tricky. I would like to ask for experienced users how then handle and balance their topojson simplification.

What approach do you take yourself ? and so... What topojson parameters should I use to make my topojson nicer ? (no crispy stairs-steps edge, correct loyalty the the shape)

解决方案

-q VS -s

More details on Topojson: quantization VS simplification .

The total size of your geometry is controlled by two factors: the number of digits (the precision) of each coordinate and the number of points.

The quantization -q reduce the number of digits for each coordinate. Initially, geopoints have very high precision such

…,[-90.07231180399987,29.501753271000098],[-90.06635619599979,29.499494248000133],…

Quantization -q 1e4 where 1e4=10000 creates a 10,000×10,000 grid with integer values between 0 and 9999 such [-6700,1030]. Characters by coordinate is reduced from ~40 to 12, a ~75% reduction, with a maximum of 4 digits by value. Secondly, quatization makes geopoints which where distinct in the input shapefile to now share the same coordinates, such [24,62],[24,62],[24,62]…. These duplicates are merged. The end result are shapes defined by points on the grids. If you ONLY use the quantization your shapes will be made of vertical + horizontal lines from grid-point to grid-point.

In contrast, simplification removes information by removing points. The Visvalingam method used by the TopoJSON removes the least-noticeable points, the principle is wittily illustrated in Line Simplification article. To have many fine triangles to delicately removes, first use a higher quantization, then a simplification :

 #world
 topojson -q 1e6 -s 7e-5 -o world-110m.json -- NaturalEarth-110m.shp

It's the simplification which by removing some corner points create diagonals lines in topojson-based shapes.

-s

Asked on google group, M. Bostock proposed some smart tips.

  1. For the USA, use -s 7e-7. "e" stands for exponent, measured in steradians for spherical coordinates. 7e-8 is ten times smaller, which is a lot more detail! 7e-5 is one hundred times less details.

Lately, I’ve started pre-projecting the TopoJSON. This allows you to specify an intuitive simplification threshold in screen pixels (--cartesian --width 960 -s 1 for one square pixel, e.g.) and makes rendering very fast on the client since the TopoJSON is already projected.

Demos

Two live use and an other are such :

# projected (giving node extra memory since input shapefile is big)
us-albers.json: County_2010Census_DP1.shp
    node --max_old_space_size=8192 node_modules/.bin/topojson \
        -q 1e5 \
        -s 1 \
        --projection 'd3.geo.albersUsa()' \
        --id-property=GEOID10 \
        -p name=NAMELSAD10,pop=+DP0010001 \
        -o $@ \
        -- counties=County_2010Census_DP1.shp

# non-projected (not used by this example, but included for reference)
  topojson --max_old_space_size=8192 \
     -q 1e6 \
     -s 7e-5 \
     -o world-110m.json \
     -- NaturalEarth-110m.shp
#USA
  topojson \
    -q 1e5 \
    -s 7e-7 \
    --id-property=GEOID10 \
    -p name=NAMELSAD10,pop=+DP0010001 \
    -o $@ \
    -- counties=County_2010Census_DP1.shp

With unprojected, as your mapped area's dimensions get 10 times smaller (i.e. Nevada), the 7e-7 should move to smaller values such 7e-8.

Cartesian

http://bost.ocks.org/mike/simplify/

这篇关于脆皮边缘与topojson?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆