Open levyj opened 5 years ago
Just as a note, this issue is partly an invitation for someone to try to take on this feature request but at least as much a way to document the underlying structure. Especially as time passes, if anyone plans to rely on the information, whether to attempt the feature or for any other reason, it might be a good idea to confirm any critical portions with the RSocrata team and/or Socrata (https://github.com/socrata / https://dev.socrata.com/).
Socrata's Spatial Lens (most prominently used in map view filters) determines the geographic regions (e.g., Chicago Community Area) in which a point record falls. These regions are not presented in an easily understood way in either the grid view of a dataset or the /resource API but can be determined through a multi-step process. It would be great service if RSocrata could perform this process and return the calculated regions, if present.
As an example, see https://data.cityofchicago.org/Buildings/Building-Violations/22u3-xenr.
The /resource API shows an example record:
Note in particular:
":@computed_region_vrxf_vc4k": "59"
The /views API shows us under columns:
So, that value is the Community Area but the value is not, as it might appear, Community Area 59. Instead, examine https://data.cityofchicago.org/dataset/Community-Areas/vrxf-vc4k. (Note the conversion of the underscore from the
computed_region
value to a hyphen.) The 59 refers to the record in this dataset with_feature_id
59, which turns out to be Community Area 61. (As I discovered in working through this example, the Feature IDs and Community Areas do match in many cases, which could lead people to think, incorrectly, that the:@computed_region_vrxf_vc4k
is the Community Area number, itself.)The final step is determining which column in this dataset shows the relevant value (Community Area, in this case). It should be fairly apparent to a person which column to use so, given the fairly small number of computed regions (types of regions, not the individual regions) likely used on a domain, it might be feasible to leverage that in some manner. However, there is an API. For the record, Socrata gave me the following warning, which I wish to record here:
That said, if we consult https://data.cityofchicago.org/api/curated_regions and search for
vrxf-vc4k
, we see:The item of interest is:
"geometryLabel": "community"
That is, in fact, the API field name from https://data.cityofchicago.org/dataset/Community-Areas/vrxf-vc4k indicating the Community Area, although it is worth noting that the value in this column for the above example is not
61
butNEW CITY
, the name of the Community Area, rather than the number.