在一个命令中切换到topojson WITH filtering



我通常看到并使用第一个ogr2ogr命令从.shp转换到.geoJSON。在第二个命令中,我使用topojson.js.geoJSON格式转换为.topoJSON格式,简化了精度、坐标、弧线和过滤,只保留相关的元数据。例子:

# DOWNLOAD: Data from http://gadm.org/
CRI_adm.zip:
    curl -o CRI_adm.zip http://gadm.org/data/shp/CRI_adm.zip
CRI_adm0.shp: CRI_adm.zip
    unzip CRI_adm.zip
    touch CRI_adm0.shp
# PROCESS DATA: SIMLIFY, FILTER
costarica.json: CRI_adm0.shp
    ogr2ogr -f GeoJSON costarica.json CRI_adm0.shp
# Require topojson: https://github.com/mbostock/topojson
# (this minifies/simplifies the data)
costarica_min_topo.json: costarica.json
    topojson 
        -p name=NAME 
        -p name 
        -q 1e4 
        -o costarica_min_topo.json 
        costarica.json

但是,由于topojson.js可以直接从.shp转换为.topoJSON,通过简化精度、坐标、弧线、,我们是否可以跳过ogr2ogr,直接用一个topojson.js命令转换和过滤呢?

# PROCESS DATA: SIMLIFY, FILTER
    topojson 
        -p name=NAME 
        -p name 
        -q 1e4 
        -o costarica_min_topo.json 
        CRI_adm0.shp

ogr2ogr有一个-where参数。您可以使用-where "name= name "来过滤shp文件

的特性。

最新更新