[R-sig-Geo] Timezone boundaries (for adding to world map)?
Roger Bivand
Roger.Bivand at nhh.no
Wed Feb 25 19:11:35 CET 2009
On Wed, 25 Feb 2009, Roger Bivand wrote:
> On Tue, 24 Feb 2009, Martin Maechler wrote:
>
>>>>>>> "RB" == Roger Bivand <Roger.Bivand at nhh.no>
>>>>>>> on Fri, 20 Feb 2009 09:55:52 +0100 (CET) writes:
>>
>> RB> On Wed, 18 Feb 2009, Greg Snow wrote:
>> >> There is a shapefile (works well with maptools and sp packages) with
>> a
>> >> world map and time zone information at:
>> >> http://openmap.bbn.com/data/shape/timezone/
>> >>
>> >> It has the info needed to color the countries or parts of countries
>> >> based on time zone, but does not have polygons for time zone stripes
>> >> over the oceans.
>>
>> RB> In fact, this shapefile provoked an update in sp, because it is
>> really
>> RB> buggy.
>>
>> I'm happy to have provoked progress ;-) :-)
>>
>> RB> There are straight-line polygons and many others have multiple
>> RB> repeated coordinates (the sp update fixes these to retain finite
>> label
>> RB> points), but it doesn't fix the absence of most of the data (several
>> DBF
>> RB> columns are empty - checked in oocalc):
>>
>> >> library(rgdal)
>> >> tz <- readOGR(".", "WrldTZA")
>> RB> OGR data source with driver: ESRI Shapefile
>> RB> Source: ".", layer: "WrldTZA"
>> RB> with 1890 rows and 11 columns
>> RB> Feature type: wkbPolygon with 2 dimensions
>> RB> Warning messages:
>> RB> 1: In Polygon(cbind(jG[[1]], jG[[2]])) :
>> RB> Non-finite label point detected and replaced
>> RB> 2: In Polygon(cbind(jG[[1]], jG[[2]])) :
>> RB> Non-finite label point detected and replaced
>> RB> 3: In Polygon(cbind(jG[[1]], jG[[2]])) :
>> RB> Non-finite label point detected and replaced
>> >> names(tz)
>> RB> [1] "FIPS" "NAME" "COMMENTS" "REGION" "LAT" "LON"
>> RB> [7] "TZ" "GMTOFF" "LOCALSUM" "OFFSET" "CLASSES"
>> >> summary(tz$GMTOFF)
>> RB> NA's
>> RB> 1890
>> >> summary(tz$TZ)
>> RB> NA's
>> RB> 1890
>> >> summary(tz$OFFSET)
>> RB> 0 \xff0 -1 \xff-1 \xff+1 -10 +10
>> RB> 25 57 13 7 181 24 38
>> RB> \xff+10 +10.5 +11 +11.5 +12 \xff+12 +2
>> RB> 24 1 19 3 12 13 1
>> RB> \xff-2 \xff+2 +3 \xff-3 \xff+3 -3.5 \xff+3.5
>> RB> 4 90 59 146 25 7 3
>> RB> -4 +4 \xff-4 \xff+4 \xff+4.5 -5 +5
>> RB> 56 4 165 8 1 130 13
>> RB> \xff-5 \xff+5 \xff+5.5 \xff+5.75 -6 +6 \xff-6
>> RB> 12 3 16 1 77 10 16
>> RB> \xff+6 \xff+6.5 -7 +7 \xff+7 -8 +8
>> RB> 12 15 63 98 14 61 68
>> RB> \xff-8 \xff+8 -9 +9 \xff+9 +9.5 NA's
>> RB> 3 56 82 97 13 11 33
>>
>> RB> where my locale is UTF-8.
>>
>> RB> I wrote to Martin offline that a more recent link is:
>>
>> RB> http://efele.net/maps/tz/world/
>>
>> RB> and I've put tz_world.rda on http://spatial.nhh.no/R/etc, but it is
>> not
>> RB> line generalised, so it is very large and takes a long time to
>> display -
>> RB> they've kept a lot of boundary detail.
>>
>> indeed. But thanks a lot to make it available!!
>>
>> RB> Because TZ follow administrative boundaries, they are actually hard
>> to do
>> RB> right. Maybe a raster version might help more if vector precision
>> isn't
>> RB> needed?
>>
>> as long as we can add a couple of cities (using geographical
>> coordinates) to it, afterwards, that's fine.
>>
>> When I load your (above URL) tz file and plot it,
>> I get the impression that much time is spent on thousands of
>> very small polygons;
>> consequently, if I'd want a ``subset'' of tz that only contains
>> the polygons that correspond to areas larger than, say, 100 km^2,
>> how could I do that ?
>
> I've put simpl_tz.rda on the same site with the smaller non-principal islands
> removed, so it plots faster. However, attempts to do line simplification to
> reduce the detail on coastlines have not yet succeeded.
>
> Anyone like to try to do the line simplification? In GRASS, I'm seeing
> "Attempt to read dead line" after both v.generalize and v.simplify.
>
> Compared to the original object, this one has very many fewer constituent
> Polygons objects, because all the geometries with the same time zone have
> been collected into single Polygons objects, rather than being almost all
> singletons. This has also speeded up plotting.
And a raster version, same site, SGDF_tz.rda. Then:
image(SGDF, "tzn", col=rainbow(300))
plots a map.
Roger
>
> Hope this helps,
>
> Roger
>
>
>>
>> Looking at the sp-object:
>>
>> ------------------------------------------------------------------------
>>
>> load("tz_world.rda")
>>
>> ## Look a bit at the 'tz' object:
>> str(tz, max=2)
>> ## Formal class 'SpatialPolygonsDataFrame' [package "sp"] with 5 slots
>> ## ..@ data :'data.frame': 27704 obs. of 1 variable:
>> ## .. ..- attr(*, "data_types")= chr "C"
>> ## ..@ polygons :List of 27704
>> ## ..@ plotOrder : int [1:27704] 24471 111 14349 24641 1598 10291 22351
>> ...
>> ## ..@ bbox : num [1:2, 1:2] -180 -90 180 83.6
>> ## .. ..- attr(*, "dimnames")=List of 2
>> ## ..@ proj4string:Formal class 'CRS' [package "sp"] with 1 slots
>>
>> ltz <- sapply(slotNames(tz), slot, object=tz)
>> sapply(ltz, object.size)
>> ## data polygons plotOrder bbox proj4string
>> ## 1690424 110706296 110856 704 704
>>
>> str(tz at data[,1])
>> ## Factor w/ 382 levels "Africa/Abidjan",..: 307 307 307 307 307 307 ...
>>
>> str(head(tz at polygons[1:3]), max=1)
>> ## List of 3
>> ## $ :Formal class 'Polygons' [package "sp"] with 5 slots
>> ## $ :Formal class 'Polygons' [package "sp"] with 5 slots
>> ## $ :Formal class 'Polygons' [package "sp"] with 5 slots
>>
>> ------------------------------------------------------------------------
>>
>> and then ask for
>>
>> showMethods(class = "Polygons")
>>
>> the result is not so revealing to me; but of course, I'm really
>> an sp greenhorn.
>>
>> How could I compute areas?
>>
>> Regards,
>> Martin
>>
>>
>>
>> RB> Roger
>>
>> >>
>> >> Hope this helps,
>> >>
>> >>
>>
>> RB> --
>> RB> Roger Bivand
>> RB> Economic Geography Section, Department of Economics, Norwegian
>> School of
>> RB> Economics and Business Administration, Helleveien 30, N-5045 Bergen,
>> RB> Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
>> RB> e-mail: Roger.Bivand at nhh.no
>>
>
>
--
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Helleveien 30, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 95 43
e-mail: Roger.Bivand at nhh.no
More information about the R-sig-Geo
mailing list