<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body bgcolor="#FFFFFF" text="#333333">
    <p>Hi Jon,</p>
    <p>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.</p>
    <p>Cheers,</p>
    <p>Frank<br>
    </p>
    <div class="moz-cite-prefix">Le 31/10/2018 à 12:35, Jón Eiríksson a
      écrit :<br>
    </div>
    <blockquote type="cite"
      cite="mid:3B3C1EB6-F4E8-4035-A14C-6408B663538E@hi.is">
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
      <div style="font-family:sans-serif">
        <div style="white-space:normal">
          <p dir="auto">The following partial script may be helpful
            (having the source map in shape format):</p>
          <h1 style="font-size:1.4em">assume folder in home directory
            containing source map - in this case contours.shp</h1>
          <h1 style="font-size:1.4em">v_w,v_s,v_e,v_n are string
            variables with destination region</h1>
          <h1 style="font-size:1.4em">the commands create a subset
            defined by the destination region: contours.shp</h1>
          <h1 style="font-size:1.4em">note that the identical naming of
            input and output is perhaps confusing but harmless</h1>
          <h1 style="font-size:1.4em">as long as the home directory does
            not contain files named contours.*</h1>
          <h1 style="font-size:1.4em">—</h1>
          <h1 style="font-size:1.4em">importing required modules</h1>
          <p dir="auto">import os<br>
            import sys<br>
            import subprocess<br>
            from array import array<br>
            import string<br>
            import math<br>
            from grass.script import core as grass<br>
            from grass.script import db as grass</p>
          <h1 style="font-size:1.4em">excerpt</h1>
          <pre style="background-color:#F7F7F7; border-radius:5px 5px 5px 5px; margin-left:15px; margin-right:15px; max-width:90vw; overflow-x:auto; padding:5px" bgcolor="#F7F7F7"><code style="background-color:#F7F7F7; border-radius:3px; margin:0; padding:0" bgcolor="#F7F7F7">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')
</code></pre>
          <p dir="auto">Jon</p>
          <p dir="auto">On 31 Oct 2018, at 10:12, Frank David wrote:</p>
        </div>
        <div style="white-space:normal">
          <blockquote style="border-left:2px solid #777; color:#777;
            margin:0 0 5px; padding-left:5px">
            <p dir="auto">Hello,<br>
              <br>
              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).<br>
              Thank you for your advice !<br>
              <br>
              Frank<br>
              _______________________________________________<br>
              grass-user mailing list<br>
              <a class="moz-txt-link-abbreviated" href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br>
              <a
                href="https://lists.osgeo.org/mailman/listinfo/grass-user"
                style="color:#777" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/grass-user</a></p>
          </blockquote>
        </div>
      </div>
    </blockquote>
  </body>
</html>