[GRASS-user] partial vector copy to smaller territory

Frank David frank.david at geophom.fr
Wed Oct 31 05:16:56 PDT 2018


Hi Jon,

Thanks for your reply. It's very interesting to make a python script, 
even if the input data doe not come from grass database as I would like.

Cheers,

Frank

Le 31/10/2018 à 12:35, Jón Eiríksson a écrit :
>
> The following partial script may be helpful (having the source map in 
> shape format):
>
>
>   assume folder in home directory containing source map - in this case
>   contours.shp
>
>
>   v_w,v_s,v_e,v_n are string variables with destination region
>
>
>   the commands create a subset defined by the destination region:
>   contours.shp
>
>
>   note that the identical naming of input and output is perhaps
>   confusing but harmless
>
>
>   as long as the home directory does not contain files named contours.*
>
>
>>
>
>   importing required modules
>
> import os
> import sys
> import subprocess
> from array import array
> import string
> import math
> from grass.script import core as grass
> from grass.script import db as grass
>
>
>   excerpt
>
> |cmd = 'ogr2ogr -clipsrc' + ' ' + v_w + ' ' + v_s + ' ' + v_e + ' ' + 
> v_n cmd = cmd + ' ' + '~/contours.shp' + ' ~/folder_name/contours.shp' 
> subprocess.call(cmd, shell = True) grass.run_command('v.in.ogr', 
> input='contours.shp', layer='contours', output='contours') |
>
> Jon
>
> On 31 Oct 2018, at 10:12, Frank David wrote:
>
>     Hello,
>
>     What is the best and fast way to make a copy of a part of vector
>     map (national) to get a smaller territory ? (partial copy).
>     Thank you for your advice !
>
>     Frank
>     _______________________________________________
>     grass-user mailing list
>     grass-user at lists.osgeo.org
>     https://lists.osgeo.org/mailman/listinfo/grass-user
>
-------------- section suivante --------------
Une pièce jointe HTML a été nettoyée...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20181031/81bc5af4/attachment.html>


More information about the grass-user mailing list