Posts Tagged ‘example’

Simple shapefile drawing in ActionScript 3 (Cartogrammar)

Wednesday, July 29th, 2009

Shapefile + magic = map in Flash!

[Editor's note: Andy Woodruff explains how to use his quick and easy implementation of Edwin van Rijkom's AS3 classes for loading SHP files and their DBF attributes into Flash/Flex. This library DOES NOT PROJECT your shp files, you might consider doing that first.]

Recently I’ve heard two friends independently inquire about some sort of basic guide for loading and drawing a shapefile in Flash. The only real tutorial/example I can recall is here, dealing with Google Maps. But these guys are looking for something more bare-bones. Being a regular user of Edwin van Rijkom’s invaluable code libraries for reading shapefiles, and usually forgetting the process myself, I thought it would be a good idea to put together a very simple set of AS3 classes that load a shapefile and throw a map on screen.

So to get those jerks off my back, I wrote a little thing called ShpMap, which supplements van Rijkom’s classes by loading and drawing a shapefile. It’s nothing fancier than that. Sometimes all you need is to get your base map on screen. (Update: just to round it out a little more, I’ve added basic loading and parsing of a shapefile’s accompanying DBF file, which contains attribute data. This also uses classes by van Rijkom.)

I hope that this class (and the several associated classes) can both be directly usable for some projects and serve as a basic guide to using van Rijkom’s classes to load shapefiles.

Dig it:

  • An example that loads and displays a US states shapefile (and then puts a square on my house and colors the state of Wisconsin green). View the source code here.
  • Download the source code. (My classes plus van Rijkom’s, as well as a demo US States shapefile.)

Gas Woe’s for Europe (Wash Post)

Thursday, January 8th, 2009

[Editor's note: Beautiful, compact map in Thursday's paper showing 4 main natural gas pipelines feeding Europe from Russia on a globe. I think this map is by Laris Karklis. He even has the Arctic Circle on there!]

Republished from The Washington Post. By Philip P. Pan. Thursday, January 8, 2009; Page A08

Economy, Politics Stoke Russia-Ukraine Gas Quarrel
Deliveries Halted To European Users As Feud Deepens 

MOSCOW, Jan. 7 — Since the fall of the Soviet Union, Russia and Ukraine have wrangled over fuel prices, with both sides holding a powerful bargaining chip. Russia has had the natural gas Ukraine needs to power its industries. Ukraine has owned the pipelines Russia depends on to transport the gas it sells to Europe.

The two have often engaged in brinkmanship, threatening to cut off deliveries. But they have never followed through on the threats for very long – until now.

A confluence of factors tied to the global economic crisis and political uncertainty in both countries have altered the dynamics of the annual dispute. For the first time, Russian gas deliveries to Europe through Ukraine came to a complete halt Wednesday, as the standoff between the two countries stretched into a seventh day.

Russia accused Ukraine of shutting down pipelines that deliver a fifth of the continent’s fuel, while Ukraine charged that Russia had simply stopped sending gas. With more than a dozen countries scrambling to maintain heat and electricity amid a bitter cold snap, the European Union urged both countries to accept international monitors to verify gas flows.

Direct talks were scheduled to resume Thursday, but analysts said progress would be difficult for the same mix of economic and political reasons that led the two nations to dig in this week instead of compromising, as they had done in years past.

With its economy in deep trouble, Ukraine has little to lose by using its control of European fuel shipments to resist Russia’s demand for a price increase. By contrast, Russia is suffering huge losses in immediate gas revenue and enormous damage to its reputation as an energy partner seeking European investment. Yet political considerations seem to have prevented the Kremlin from surrendering.

Continue reading at Washington Post . . .

Map Scale Calculator Tools? (Kelso)

Monday, December 15th, 2008

Do you know of any good tools for converting a map’s graphic scale bar measurement to a representational fraction (RF)? Please share them! We often think of maps as 1:24,000 or 1:1,000,000 natural scale but more often than not a scale bar is the only indication of scale we have on a map. How to convert that back to the more familiar representational fraction?

What are the features and interface you’d like to see for such a tool?

The best that I’ve been able to dig up is:

From Oregon State University Library
http://oregonstate.edu/~reeset/html/scale.html

Type in the number of units per distance (or distance per unit) and it’ll return the relational fraction. It does not do a very good job allowing you to type in both the units and the distance as variable. I hardly ever find scale bars on maps that are exactly an inch long. So involves some pre-math to get this tool to work.

Screenshots below:

This University of Texas site does the opposite:
http://www.beg.utexas.edu/GIS/tools/scale2.htm

Enter the representational fraction of the map and get “1 inch = X miles” verbal statements where the left and right terms do not have the same units.

Then there is the general problem of converting between map units.

Google provides the most ready answer:
Type in “convert 12 miles to km” and it will return the conversion.

The same OSU site also has a version:

Read more about map scales.

Some example map scales and worked formula examples from Richard Layton (source).

  • 1 inch equals 10 miles
  • 1 inch = 10 miles
  • 1 inch = 10 miles x 12 inches/foot x 5280 feet/mile
  • 1 inch = 10 x 63360 inches = 633,600 inches
  • 1:633,600

To convert from RF to Verbal Scale you convert the fraction to familiar units of measurements; for example:

  • 1:250,000
  • 1 inch = 250,000 inches
  • 1 inch = 250,000 inches [d] 12 inches/foot = 20,833.3 feet
  • 1 inch = 20,833.3 feet [d] 5280 feet/mile = 4 miles or
  • 1 inch = 250,000 [d] 63360 inches/mile = 4 miles
  • 1 inch equals 4 miles

[Note: [d] = divided by]

SOME COMMON SCALES. Here is a list of RF scales commonly used in the Map Collection and their equivalent Verbal Scales.

  • 1:24,000 - 1 in. = .379 mi.
  • 1:62,500 - 1 in. = .986 mi.
  • 1:100,000 – 1 in. = 1.578 mi.
  • 1:250,000 - 1 in. = 4 mi.
  • 1:500,000 - 1 in. = 7.891 mi.
  • 1:1,000,000 – 1 in. = 15.783 mi.

For example you want a map of Arizona on a 8 1/2 x 11 inch piece of paper. To allow for 1/2-inch margins the new sheet will then be 7 1/2 x 10 inches. Since Arizona’s north-south dimension, 395 miles, is slightly longer than its east-west dimension, 340 miles, we will place the longer north-south dimension along the longer 10-inch dimension of the paper. The next step is to compute the scales for both dimensions of the State. The smaller of the two scales will be the one we need.

North-south
10 in = 395 mi
10 in = 395 mi x 63360 in/mi
10 in [d] 10 = 25027200 in [d] 10
1 in = 2502720 in
1:2,502,720

East-west
7.5 in = 340 mi
7.5 in = 340 mi x 63360 in/mi
7.5 in [d] 7.5 = 21542400 in [d] 7.5
1 in = 2872320 in
1:2,872,320

[Note: [d] = divided by]

We therefore need a map of Arizona at a scale of 1:2,872,320 or less to place it on an 8 1/2 x 11 inch sheet of paper.

Scale

Miles/inch

Line
Width on Ground*

Examples

1:2,000,000

~32

2000’

USGS
Nation-wide maps

1:1,000,000

~16

1000’

National and
state maps

1:500,000

~8

500’

State or
regional maps

1:250,000

~4

250’

US Army Map
Series

1:100,000

~1.6

100’

USGS 30′
quads

1:62,500

5208 feet

62.5’

USGS 15′
quads

1:24,000

2000 feet

24’

USGS 7′
quads

1:15,840

1320 feet

15.84’

Soils

1:9,600

800 feet

Aerial
photos

*Approximate real width on ground of a pencil line on a map – harder pencils give a finer line

1:2,000,000 to about 1:250,000 are SMALL-scale maps. Items on these maps appear small (e.g. a county on a 1:2,000,000 map is much smaller than on a 1:100,000 map).

1:24,000 on towards 1:9,600 are LARGE-scale maps. Items on these maps appear larger. 1:100,000 are
pretty much in the middle – intermediate scale.