Working with Shapefiles in IDL

As a follow-up to the Using Map Projection Routines in IDL webinar, I wanted to show an example of reading entities from an ESRI Shapefile and visualizing them in a map projection. I’ve uploaded the example program and the Shapefile used in the example to the VIS Code Library; they can be downloaded directly from here.

For data, I chose a U.S. Census Bureau 2008 TIGER/Line® Shapefile containing county boundaries for the state of Colorado. This Shapefile, and others for Colorado, can be obtained from the U.S. Census Bureau at http://www2.census.gov/cgi-bin/shapefiles/state-files?state=08.

In the example program, NG_COLORADO_COUNTIES, a user can pass the name of a Colorado county as a string. The shape for the county is extracted from the Shapefile and displayed on a map projection. For example, to display Summit County, call NG_COLORADO_COUNTIES with:

IDL> ng_colorado_counties, 'Summit', fill_color='dodger blue'

Here’s the result:
Summit County, Colorado
Please try the example and read over the code—I tried to explain each step of the process: reading entities from the Shapefile, setting up a map projection and visualizing the entities in the map projection. If you have any questions, please let me know in the comments!

About these ads

About Mark

I solve scientific programming and visualization problems with IDL.
This entry was posted in data access, output, visualization and tagged , , , , . Bookmark the permalink.

One Response to Working with Shapefiles in IDL

  1. Hello there,
    Your code is really interesting for me but for some reason IDL cries on this line:

    map = map(‘Orthographic’, limit=[minlat, minlon, maxlat, maxlon], $
    center_longitude=0.5*(minlon+maxlon), title=county_names[i_county] + ‘ County, Colorado’, $ color=’gray’, label_position=0)

    % Unable to concatenate variables because the dimensions do not agree: .

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s