I have just discovered Geo::ShapeFile module that gives perl the means to access the geometry of Esri shapefiles.
Although I have been successful in getting the x and y co-ords I have not been able to get the z (height) values from my shapefile.
Anyone else using this module and experience the same problem ??
Below is the code I wrote to get the x,y co-ords and z (height) values for a test shapefile.
use Geo::ShapeFile::Point comp_includes_z=>0;
use Geo::ShapeFile;
#reads the "test3D" shapefile layer.
$shapefile = new Geo::ShapeFile("test3D");
#loops throught each shapefile and gets the shape
#for each record
for (1 ..$shapefile->shapes){
$shape = $shapefile->get_shp_record($_);
#puts the points into an array of hashes
@point = $shape->points;
#for each point get the x,y co-ords and the
#(hieght) values and print
foreach $p (@point){
$x=$p->X;
$y=$p->Y;
$z=$p->Z;
print "$x, $y, $z \n";
}
}
Any help is greatly appricated.
Penny
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.