dabreegster / odjitter

Disaggregate zone-based origin/destination data to specific points
Apache License 2.0
12 stars 6 forks source link

Issue when zone/origin/destination codes are numeric in R package #35

Closed Robinlovelace closed 2 years ago

Robinlovelace commented 2 years ago

Non reproducible example based on data I'm using:

Before the update:

od_leeds_50_plus_jittered = odjitter::jitter(
+   od = od_to_jitter,
+   zones = zones_leeds %>% sf::st_cast("MULTIPOLYGON"),
+   subpoints_origins = osm_lines_leeds,
+   subpoints_destinations = schools_leeds,
+   zones_d = zones_d %>% sf::st_cast("MULTIPOLYGON"),
+   disaggregation_threshold = 10
+ )
Error: Feature doesn't have a string zone name geo_code: Feature { bbox: None, geometry: Some(Geometry { bbox: None, value: MultiPolygon([[[[-1.595245805167649, 53.825986620393714], 

After...

Robinlovelace commented 2 years ago

It works!

> od_to_jitter = od_leeds_50_plus %>%
+   select(geo_code1 = LSOA11, geo_code2= laestab, pupils, pupilstest = pupils / 10) %>%
+   sf::st_drop_geometry()
> od_leeds_50_plus_jittered = odjitter::jitter(
+   od = od_to_jitter,
+   zones = zones_leeds %>% sf::st_cast("MULTIPOLYGON"),
+   subpoints_origins = osm_lines_leeds,
+   subpoints_destinations = schools_leeds,
+   zones_d = zones_d %>% sf::st_cast("MULTIPOLYGON"),
+   disaggregation_threshold = 10
+ )
Scraped 1187 zones from /tmp/RtmpB2V1lN/zones.geojson
Scraped 257719 subpoints from /tmp/RtmpB2V1lN/subpoints_origins.geojson
Scraped 759 subpoints from /tmp/RtmpB2V1lN/subpoints_destinations.geojson
Disaggregating OD data
Wrote /tmp/RtmpB2V1lN/od_jittered.geojson
> od_leeds_50_plus_jittered
Simple feature collection with 6792 features and 3 fields
Geometry type: LINESTRING
Dimension:     XY
Bounding box:  xmin: -1.781018 ymin: 53.70006 xmax: -1.293796 ymax: 53.94184
Geodetic CRS:  WGS 84
# A tibble: 6,792 × 4
   geo_code1 geo_code2 pupilstest                                 geometry
   <chr>     <chr>          <dbl>                         <LINESTRING [°]>
 1 E01011506 3834041         8.86  (-1.544378 53.83747, -1.551637 53.8347)
 2 E01011506 3834041         8.86   (-1.544239 53.8364, -1.551637 53.8347)
 3 E01011506 3834041         8.86   (-1.543042 53.8394, -1.551637 53.8347)
 4 E01011506 3834041         8.86  (-1.543617 53.83887, -1.551637 53.8347)
 5 E01011506 3834041         8.86  (-1.543564 53.83748, -1.551637 53.8347)
 6 E01011506 3834041         8.86  (-1.543093 53.83965, -1.551637 53.8347)
 7 E01011506 3834041         8.86  (-1.542796 53.84006, -1.551637 53.8347)
 8 E01011725 3832493 
Robinlovelace commented 2 years ago

image