Hi,
Hab die ersten Korrekturen eingescheckt.
Dann muss ich ja fuer die Geofabrik-Exporte jetzt regelmaessig neue
Polygone holen ;-)
BTW download.geofabrik..de hat das letzte mal am 29.01 neue Dateien
ertstellt.
Kuemmere mich grade drum. Wir hatten hier in Karlsruhe einen
groesseren Stromausfall, der einiges durcheinandergebracht hat.
Magst du mir noch erklären, wie du aus dem Shape File ein Polygon
Datei
gemacht hast?
Mit einem Perl-Skript, das auf der Geo::Shapfile-Library basiert. Ich
habe ein sehr spezielles fuer die Bundeslaender gemacht, spaeter
aber, weil ein Englaender fragte, eine relativ allgemeine Version
programmiert, hier anhaengend. Da ist eine Zeile mit "this" und
"that" drin, die man anpassen muss, je nachdem, welche Shapes man
eben rausziehen will.
Ich kann die GADM-Daten aber nicht unbedingt empfehlen, sie sind sehr
lueckenhaft. Ich hatte fuer die Englaender mal deren Liste der
administrativen Untereinheiten da rausgezogen, und da fehlte die
Haelfte.
#!/usr/bin/perl
use Geo::ShapeFile;
my $shapefile = new Geo::ShapeFile("my.shp");
# the first for loop runs through all shapes in the file and looks
# at their db entries; if they are "wanted", they are added to a list.
# each list created here will lead to one .poly file later. multiple
# shapes can be pushed onto the same list.
# IF YOUR INPUT CONTAINS JUST ONE SHAPE AND YOU SIMPLY WANT A
# POLY FILE FROM IT:
# replace the whole "for" loop by
# $shapes{"out"} = 1..$shapefile->shapes();
for (1..$shapefile->shapes ())
{
my %db = $shapefile->get_dbf_record ($_);
if ($db{"this"} eq "that") # test if the shape is wanted
{
push (@{$shapes{"shapename"}}, $_); # record shape on a stack
# named "shapename" (will lead to shapename.poly later)
}
}
# second loop writes the actual shape info into polygon files
foreach my $shpkey (keys(%shapes))
{
open (B, ">$shpkey.poly");
print B "$shpkey\n";
my $cnt=1;
foreach my $shapeid(@{$shapes{$shpkey}})
{
my $shape = $shapefile->get_shp_record ($shapeid);
for(1 .. $shape->num_parts)
{
my @part = $shape->get_part($_);
my @polypoints;
printf B "%d\n", $cnt++;
foreach my $pt(@part)
{
printf B " %E %E\n", $pt->X(), $pt->Y();
}
print B "END\n";
}
}
print B "END\n";
close(B);
}
Bye
Frederik
--
Frederik Ramm ## eMail [EMAIL PROTECTED] ## N49°00.09' E008°23.33'
_______________________________________________
Talk-de mailing list
[email protected]
http://lists.openstreetmap.org/cgi-bin/mailman/listinfo/talk-de