We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
SVG Map (Read 671 times)
SVG Map
Oct 25th, 2008, 8:45pm
 
I am trying to color code a map like the one on p 322 of Visualizing Data and I am having two problems:

The first is that many of the maps in the Wikimedia commons appear to be png files even though they have an "svg" extension.  Am I missing something?

The other problem is that I am unsure how to loop through the one svg map that I found given the changes to Processing since Visualizing Data was published (I'm using 0151).

I can draw the map on the screen but then I need a little direction on how to match the states with the data I want to color code them based on.  Can anyone provide a little direction?  Thanks!

Here's the code so far -
 
PShape m;

void setup () {
background(255);
int width = 600;
int height = 500;
size(width,height);
m = loadShape("Blank_US_map_borders_labels.svg");
smooth();
noLoop();
}

void draw(){
 shape(m, 30,30,width - (width*.10),height -(height*.10));
}
Re: SVG Map
Reply #1 - Oct 25th, 2008, 11:08pm
 
jason.mat wrote on Oct 25th, 2008, 8:45pm:
The first is that many of the maps in the Wikimedia commons appear to be png files even though they have an "svg" extension.  Am I missing something


i think it renders them as pngs for inclusion on the web pages as png has better support than svg. the actual svg file is available by right clicking the link below the picture and 'save link as'.

that map doesn't contain data for the individual states. this one does: http://upload.wikimedia.org/wikipedia/commons/3/33/USA_location_map.svg

you'll need to parse the svg to set the colour on the indvidual states - the ones that are there are currently drawn with "fill: rgb(254, 254, 233)" (and, somehow, there are 169 of those so more than one region per state)
Page Index Toggle Pages: 1