WritePoint.pl
From Wildsong
# # Pasted in from "perldoc Geo::Shapelib" # # Reads an ASCII file delimited by '|' and generates a shapefile. # use strict; use Geo::Shapelib qw/:all/; chdir('/cygdrive/c/BRIANS_JUNK/PERL'); my $file = 'station'; my $shapefile = new Geo::Shapelib { Name => $file, Shapetype => POINT, FieldNames => ['Name', 'Code', 'Founded'], FieldTypes => ['String:50','String:10','Integer:8'], }; open(DATA, "<station") || die; while (<DATA>) { chomp; # Parse the input from the ASCII file my ($station,$code,$founded,$x,$y) = split /\|/; # Stash it in the shapefile push @{$shapefile->{Shapes}},{ Vertices => [[$x,$y,0,0]] }; push @{$shapefile->{ShapeRecords}}, [$station,$code,$founded]; } # Write shapefile to disk $shapefile->save();