Breaking up shapefiles Re: [Xastir] ESRI shapefiles and dbfawk

Tom Russo russo at bogodyn.org
Fri Dec 17 02:54:19 EST 2004


On Fri, Dec 17, 2004 at 12:42:19AM -0700, we recorded a bogon-computron collision of the <jewen at shaw.ca> flavor, containing:
> > Done.  Look for the "Tools" section of 
> > http://www.swcp.com/~russo/shape_web/
> > 
> > With these two tools you should be able to extract the freeways with:
> > 
> >  split_shape_by_attributes ROADSEG freeways NATRDCLASS Freeway
> > 
> > to get a "freeways.{shp,shx,dbf}" set.
> 
> Beauty! I even managed to compile the source into exe files... Even when the
> header info wasn't where it was supposed to be! I'm just about an expert
> Linux user now!!! 8) 

What was missing?

> > You can also create a shapefile that only contains shapes 
> > whose bounding box intersects one of your choosing (using the 
> > same criterion xastir uses to decide whether to draw a shape 
> > based on the current display region).
> > 
> >   split_shape_by_bbox ROADSEG littlearea -115 -114 48 49
> > 
> > would give you a 1-degree-square shapefile.
> 
> Excellent, I will chop the file up into smaller chunks. I'm going to make
> them the same size that the B250K Toporama files are chopped up in.

Might want to wait just a bit.

I am currently working on a modification to the shapefile rendering that
uses a fast RTree lookup scheme to speed up large shapefile access.  What
it does is build a spatial index of the contents of the shapefile the first
time it's read in.  For subsequent attempts to render the file it uses the
spatial index to select only those shape numbers that would intersect the
current viewport and accesses them directly.  This would eliminate the need
to split the files up into a bazillion small ones for speed --- the slowdown
now is that if the shapefile contains 10000 shapes and 5 of them are visible,
the code reads all 10000 and checks to see if they're visible.

My toy code that built the index and queried it worked out just fine, now 
I'm trying to incorporate it into Xastir.  Might be done in a few hours.

> So, now for the next question... Can I parse out Expressways and Freeways,
> and then merge them together? They are both equivalent as far as we are
> concerned up here. It all depended on what the data entry person was
> thinking. A couple highways have chunks missing in the middle because the
> attribute changes from expressway to freeway, and back.

You're better off looking at that tiny program and making it select more than
one value for the field.  It would not be very difficult at all to change.

> In the full file, I set both freeways and expressways up to display the same
> way. I'd like to pull both out into one file. Perhaps even reclassify them
> all to freeway.

-- 
Tom Russo    KM5VY     SAR502  DM64ux         http://www.swcp.com/~russo/
Tijeras, NM  QRPL#1592 K2#398  SOC#236 AHTB#1 http://www.qsl.net/~km5vy/
 "When life gives you lemons, find someone with a paper cut."



More information about the Xastir mailing list