bin/shp2geo.js
function getCmd(program, opt) {
            var cmd,
                expr;

            if(program==='ogr2ogr') {

                if(opt==='where') {
                    expr = [
                        '-where ',
                        "\"", specs.key, " IN ",
                        "('", specs.val, "')\" ",
                        '-clipsrc ',
                        specs.bounds.join(' ')
                    ].join('');
                }
                else if(opt==='clipsrc') {
                    expr = [
                        '-clipsrc ',
                        specs.bounds.join(' ')
                    ].join('');
                }
                else  expr = '';

                cmd = [
                    "ogr2ogr -f GeoJSON",
                    expr,
                    common.geojsonDir + common.tn(r, s.name, v.name, 'geo.json'),
                    common.wgetDir + common.srcPrefix + common.bn(r, v.src, 'shp')
                ].join(' ');

            }
            else if(program==='mapshaper') {
                cmd = [
                    mapshaper,
                    common.wgetDir + common.srcPrefix + common.bn(r, v.src, 'shp'),
                    "encoding=utf8",
                    "-clip",
                    common.wgetDir + common.tn(r, s.name, specs.src, 'shp'),
                    "-filter remove-empty",
                    "-o",
                    common.geojsonDir + common.tn(r, s.name, v.name, 'geo.json')
               ].join(' ');
            }

            return cmd;
        }
function getCmd(program, opt) {
            var cmd,
                expr;

            if(program==='ogr2ogr') {

                if(opt==='where') {
                    expr = [
                        '-where ',
                        "\"", specs.key, " IN ",
                        "('", specs.val, "')\" ",
                        '-clipsrc ',
                        specs.bounds.join(' ')
                    ].join('');
                }
                else if(opt==='clipsrc') {
                    expr = [
                        '-clipsrc ',
                        specs.bounds.join(' ')
                    ].join('');
                }
                else  expr = '';

                cmd = [
                    "ogr2ogr -f GeoJSON",
                    expr,
                    common.geojsonDir + common.tn(r, s.name, v.name, 'geo.json'),
                    common.wgetDir + common.srcPrefix + common.bn(r, v.src, 'shp')
                ].join(' ');

            }
            else if(program==='mapshaper') {
                cmd = [
                    mapshaper,
                    common.wgetDir + common.srcPrefix + common.bn(r, v.src, 'shp'),
                    "encoding=utf8",
                    "-clip",
                    common.wgetDir + common.tn(r, s.name, specs.src, 'shp'),
                    "-filter remove-empty",
                    "-o",
                    common.geojsonDir + common.tn(r, s.name, v.name, 'geo.json')
               ].join(' ');
            }

            return cmd;
        }
function getCmd ( program , opt ) { var cmd , expr ; if ( program === 'ogr2ogr' ) { if ( opt === 'where' ) { expr = [ '-where ' , "\"" , specs . key , " IN " , "('" , specs . val , "')\" " , '-clipsrc ' , specs . bounds . join ( ' ' ) ] . join ( '' ) ; } else if ( opt === 'clipsrc' ) { expr = [ '-clipsrc ' , specs . bounds . join ( ' ' ) ] . join ( '' ) ; } else expr = '' ; cmd = [ "ogr2ogr -f GeoJSON" , expr , common . geojsonDir + common . tn ( r , s . name , v . name , 'geo.json' ) , common . wgetDir + common . srcPrefix + common . bn ( r , v . src , 'shp' ) ] . join ( ' ' ) ; } else if ( program === 'mapshaper' ) { cmd = [ mapshaper , common . wgetDir + common . srcPrefix + common . bn ( r , v . src , 'shp' ) , "encoding=utf8" , "-clip" , common . wgetDir + common . tn ( r , s . name , specs . src , 'shp' ) , "-filter remove-empty" , "-o" , common . geojsonDir + common . tn ( r , s . name , v . name , 'geo.json' ) ] . join ( ' ' ) ; } return cmd ; }
use ogr2ogr for clip around bound use mapshaper for clip around shapefile polygons
use ogr2ogr for clip around bound use mapshaper for clip around shapefile polygons