gisnetlogoenvelope

Is there a way to add a buffer zone to gis:set-world-envelope-ds gis:envelope-of *shapefile*


Currently,

I am using gis:set-world-envelope-ds gis:envelope-of <shapefile> to set world. However, I am getting the error message: " Cannot move turtle beyond the world's edge. error while node 18469 running SET"

Hence, I would like to add a bufferzone around it. Does anyone know how?


Solution

  • You can manually adjust the envelope values, since they are x/y bounds. Calling gis:envelope-of just returns a list of the format [x1 x2 y1 y2] which represent the boundaries of the envelope. How to adjust those depends on how much boundary you want and your projection but: here is a quick and dirty way to add a tenth of a 'span' (x1 - x2 or y1 - y2) as a buffer:

    extensions [ gis ]
    
    to setup
      ca
      let shp_path "C:/gis_example/british_columbia_administrative.shp"
      let prj_path "C:/gis_example/british_columbia_administrative.prj"
      
      gis:load-coordinate-system prj_path
      let shp gis:load-dataset shp_path
      let base_envelope gis:envelope-of shp
      
      print word "Base envelope: " base_envelope
      
      let span_x abs ( item 0 base_envelope - item 1 base_envelope )
      let span_y abs ( item 2 base_envelope - item 3 base_envelope )
      let alternating_spans ( list span_x span_x span_y span_y )
      let alternating_signs [ -1 1 -1 1 ]
      
      let expanded_envelope ( 
        map [ [ i span sign ] -> i + sign * ( 0.1 * span )  ] 
        base_envelope alternating_spans alternating_signs 
      ) 
      
      print word "Expanded envelope: " expanded_envelope
      gis:set-world-envelope-ds expanded_envelope  
      gis:set-drawing-color white
      gis:draw shp 1  
      
      reset-ticks
    end
    

    enter image description here

    Dataset downloaded from MapCruzin.com