>  Docs Center  >  Libraries  >  Coyote  >  CGDRAWSHAPES
Libraries

CGDRAWSHAPES

CGDRAWSHAPES
  This program draws the entities in a shapefile, containing latitude and
  longitude polygons or polylines, on a map projection. To draw the shapefile
  entities automatically, no matter what kind of values the polygon vertices
  have, and without a map projection, set the AUTODRAW keyword.
  It is assumed a map projection command has been issued and is in effect at
  the time this program is called. Alternatively, you can use a cgMap object,
  which will set up the map coordinate space and provide the map structure required
  for plotting in that XY map coordinate space.
  If the ATTRVALUES keyword is undefined, all entities are drawn, but only a single value
  for COLORS, FCOLORS, FILL, LINESTYLE, and THICK is allowed.
  This software can be purchased, along with other Coyote Graphic map projection
  software, from the `Coyote Store <http://www.idlcoyote.com/store/index.php?act=viewCat&catId=3>`.

Categories


    Graphics, Map Projections
     

Author


    FANNING SOFTWARE CONSULTING::
      David W. Fanning
      1645 Sheely Drive
      Fort Collins, CO 80526 USA
      Phone: 970-221-0438
      E-mail: david@idlcoyote.com
      Coyote's Guide to IDL Programming: http://www.idlcoyote.com
     

Examples


    Example using cgMap_Set to set up the map projection space::
      shapefile = Filepath(subdir=['examples','data'], 'states.shp')
      cgDisplay, 800, 700
      cgMap_Set, 37.5, -117.5, /Albers, /IsoTropic, Limit=[30, -125, 45, -108], $
          Position=[0.05, 0.05, 0.95, 0.95]
      cgDrawShapes, shapefile, AttrName='STATE_ABBR', $
          AttrValues=['CA', 'OR', 'WA', 'AZ', 'UT', 'ID', 'NV'], Thick=1, $
          FColors=['firebrick', 'grn4', 'pur4', 'tan4', 'steel blue', 'org4', 'yellow'], $
          Fill = Replicate(1, 7), Colors='charcoal'
      cgMap_Grid, LatDel = 2.0, LonDel = 2.0, /Box_Axes, Color='charcoal'
    Example using cgMap to set up the map projection space::
      shapefile = Filepath(subdir=['examples','data'], 'states.shp')
      cgDisplay, 800, 700, WID=1
      mapCoord = Obj_New('cgMap', 'Albers Equal Area', LIMIT=[30, -125, 45, -108], $
                  Position=[0.05, 0.05, 0.95, 0.95], CENTER_LATITUDE=37.5, $
                  CENTER_LONGITUDE=-117, STANDARD_PAR1=40, STANDARD_PAR2=-39)
      cgDrawShapes, shapefile, AttrName='STATE_ABBR', $
          AttrValues=['CA', 'OR', 'WA', 'AZ', 'UT', 'ID', 'NV'], Thick=1, $
          FColors=['firebrick', 'grn4', 'pur4', 'tan4', 'steel blue', 'org4', 'yellow'], $
          Fill = Replicate(1, 7), Colors='charcoal', MapCoord=mapCoord
      cgMap_Grid, LatDel = 2.0, LonDel = 2.0, /Box_Axes, Color=cgColor('charcoal'), $
            Map_Structure=mapCoord
    Example drawing the states.shp file automatically, without a map projection::
 
      shapefile = Filepath(subdir=['examples','data'], 'states.shp')
      cgDrawShapes, shapefile, /Autodraw
    Example using cgMap to set up the map projection space in a resizeable graphics window::
      shapefile = Filepath(subdir=['examples','data'], 'states.shp')
      cgWindow, WAspect=800.0/700
      mapCoord = Obj_New('cgMap', 'Albers Equal Area', LIMIT=[30, -125, 45, -108], $
                  Position=[0.05, 0.05, 0.95, 0.95], CENTER_LATITUDE=37.5, $
                  CENTER_LONGITUDE=-117, STANDARD_PAR1=40, STANDARD_PAR2=-39)
      mapCoord -> AddCmd
      cgDrawShapes, shapefile, AttrName='STATE_ABBR', $
          AttrValues=['CA', 'OR', 'WA', 'AZ', 'UT', 'ID', 'NV'], Thick=1, $
          FColors=['firebrick', 'grn4', 'pur4', 'tan4', 'steel blue', 'org4', 'yellow'], $
          Fill = Replicate(1, 7), Colors='charcoal', MapCoord=mapCoord, /AddCmd
      cgMap_Grid, LatDel = 2.0, LonDel = 2.0, /Box_Axes, Color=cgColor('charcoal'), $
            Map_Structure=mapCoord, /AddCmd

History


Modification History


      Written by David W. Fanning by modifiying DrawStates to be more
          general, 13 May 2010. DWF.
      Added the AUTODRAW keyword for automatic drawing. 15 May 2010. DWF.
      Added COMPILE_OPT idl2 to make sure all loop variables are longs. 5 July 2010. DWF.
      Corrected an aspect ratio problem with AUTODRAW and upgraded to Coyote Graphics.
          3 January 2011. DWF.
      Previous method of freeing entity pointers took 10 times times longer than freeing
          pointers as I go. Also added MinNumVerts keyword to screen out the drawing of
          small polygons. 6 October 2011. DWF.
      Wrong string case for discovering particular attributes caused them not to be drawn. 27 Oct 2011. DWF.
       

Copyright


    Copyright (c) 2011, Fanning Software Consulting, Inc.



© 2024 NV5 Geospatial Solutions, Inc. |  Legal
   Contact Us