Displaying Shapes on Maps
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'
shapefile = 'C:\IDL\data\shapefiles\co_counties.shp'
cgDisplay, 500, 500, Title='County Boundaries'
map = Obj_New('cgMap', 'UTM', Datum=8, Zone=13, Position=[0.05, 0.05, 0.95, 0.95])
cgDrawShapes, shapefile, AttrName='COUNTY', MapCoord=map, /Projected_XY
cgMap_Grid, LatDel = 2.0, LonDel = 2.0, /Box_Axes, Color='charcoal', $
Map_Structure=map
![The county boundaries from the co_counties shapefile.](https://i-blog.csdnimg.cn/blog_migrate/c7bb704c21e5041081c25939b96bc5a5.jpeg)
Drawing Shapes Automatically
shapefile = 'C:\IDL\data\shapefiles\co_counties.shp'
cgDrawShapes, shapefile, /AutoDraw