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

Tom Russo russo at bogodyn.org
Thu Dec 16 02:52:42 EST 2004


On Thu, Dec 16, 2004 at 12:17:28AM -0700, we recorded a bogon-computron collision of the <russo at bogodyn.org> flavor, containing:
> On Wed, Dec 15, 2004 at 11:11:43PM -0800, we recorded a bogon-computron collision of the <ve7did at dccnet.com> flavor, containing:
> > James:
> > 
> > How do you want Alberta chopped up?  I had a huge shapefile of BC  chopped up 
> > into smaller areas a while ago.  I think the program was Mapinfo which was 
> > used, but can't remember for sure.  I'll let you know tomorrow.
> > 
> > I'm hoping Mapinfo will read the 40M file directly.
> 
> I just wrote a 77 line C program using shapelib that can go through a 
> shapefile of any size at all and select only those shapes that lie inside
> a bounding rectangle.
> 
> Just gonna work on one that can select only shapes that match a specified
> value of a specified attribute. 
> 
> When I'm done I'll pop them both up on my shape_web web site for folks to
> play with.

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.

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.

The tools are general and not dependent on any specific shapefile definition.
They are also not that smart, but you could probably expand them to do 
other things with a little thought.

Enjoy.

-- 
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/
 "That which does not kill me is better than that which does."
    --Irving Nietzche, lesser known of the famous Nietzche twins



More information about the Xastir mailing list