You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Allow specifying areas for custom weighting in a separate file #2037
When we use areas in a custom model file we might face the issue of having to copy and paste large amounts of geojson data into the custom model file (for example city borders). This could be improved by allowing to reference another GeoJSON file used to define the area(s)? Otherwise we'd also have to duplicate the GeoJSON data, say if we want to refer to the same areas in different custom model files.
Unfortunately, this areas object is not compatible GeoJSON. So we cannot just use standard GeoJSON tools to view/create/modify the areas. In contrast, for the custom areas in custom_areas.directory each file needs to be a JsonFeatureCollection (with potentially multiple features).
So using a JsonFeatureCollection instead of the object we currently use also for the areas in custom models would make it easier to work with multiple areas and more consistent with the custom areas, but we would need some convention how to define the area names. We could use the id field (or the properties object) for this, e.g.:
This way we could easily allow multiple areas per file. The main advantage seems that this way we don't need a long list of area file names in the custom model, i.e. something like this (?):
Of course we could also allow multiple areas per file with the current format (one object where each key is the area name and each value is a GeoJson feature describing an area), but the resulting files would be neither valid GeoJSON nor would they be compatible with those in custom_areas.directory. Then again it might be the easiest thing we could do without changing much.
Another option would be allowing only one feature per file and using a folder structure and some wildcard syntax to organize the files and reference the areas in the custom models. Something like this:
# files are organized in sub-directories
custom_areas_dir
| - eu
| - ger
| - berlin
| - area1
| - area2
...
and this:
"area_files": [ "eu/ger/berlin/*"]
Anyway, I think the first question is: Should we allow/change/extend the current custom model format to support JsonFeatureCollection?
To me this seems useful, but supporting both the old and the new format is not ideal either, because of the different schema. Dropping the old format would be a breaking change and the syntax becomes more verbose in case one uses only one area for example.
So if we change the format, we should of course use JsonFeatureCollection for the new custom model area files as well. It would be easy to allow multiple areas per file and they would be compatible with the custom areas in custom_areas.directory. We could even allow sub-directories and wildcards to reference these files in the custom models on top of this.
If no, we should either simply carry over the current format to the new files or use only one area/Feature per file, use the file name as area name and maybe allow using the sub-directories + wild-cards for more convenience.
Yeah the areas is not a GeoJSON: this is ugly for the client-side, but there we could display the areas directly in the map?
And for the server-side we could use command line tools like jq to pick a single area or transform it into a JsonFeatureCollection. Or what if we make by default all areas in custom_areas available in a custom_model too with in_<id> and for id we use custom_areas.features.id?
(Supporting a JsonFeatureCollection for a single area would be interesting too, but this is for another issue :) )
Activity
easbar commentedon Jul 26, 2022
Currently we use an object where the keys are the area names and the values are GeoJSON features to specify areas in custom-models:
Unfortunately, this
areasobject is not compatible GeoJSON. So we cannot just use standard GeoJSON tools to view/create/modify the areas. In contrast, for the custom areas incustom_areas.directoryeach file needs to be a JsonFeatureCollection (with potentially multiple features).So using a JsonFeatureCollection instead of the object we currently use also for the areas in custom models would make it easier to work with multiple areas and more consistent with the custom areas, but we would need some convention how to define the area names. We could use the
idfield (or thepropertiesobject) for this, e.g.:This way we could easily allow multiple areas per file. The main advantage seems that this way we don't need a long list of area file names in the custom model, i.e. something like this (?):
vs. this:
Of course we could also allow multiple areas per file with the current format (one object where each key is the area name and each value is a GeoJson feature describing an area), but the resulting files would be neither valid GeoJSON nor would they be compatible with those in
custom_areas.directory. Then again it might be the easiest thing we could do without changing much.Another option would be allowing only one feature per file and using a folder structure and some wildcard syntax to organize the files and reference the areas in the custom models. Something like this:
and this:
Anyway, I think the first question is: Should we allow/change/extend the current custom model format to support JsonFeatureCollection?
To me this seems useful, but supporting both the old and the new format is not ideal either, because of the different schema. Dropping the old format would be a breaking change and the syntax becomes more verbose in case one uses only one area for example.
So if we change the format, we should of course use JsonFeatureCollection for the new custom model area files as well. It would be easy to allow multiple areas per file and they would be compatible with the custom areas in
custom_areas.directory. We could even allow sub-directories and wildcards to reference these files in the custom models on top of this.If no, we should either simply carry over the current format to the new files or use only one area/Feature per file, use the file name as area name and maybe allow using the sub-directories + wild-cards for more convenience.
karussell commentedon Jul 27, 2022
Yeah the
areasis not a GeoJSON: this is ugly for the client-side, but there we could display the areas directly in the map?And for the server-side we could use command line tools like
jqto pick a single area or transform it into a JsonFeatureCollection. Or what if we make by default all areas in custom_areas available in a custom_model too within_<id>and foridwe usecustom_areas.features.id?(Supporting a JsonFeatureCollection for a single area would be interesting too, but this is for another issue :) )
otbutz commentedon Jul 27, 2022
Just my two cents, but in the general discussion of breaking changes versus good tooling support, I'd choose tooling support any day.
There's just so many GIS tooling out there which supports plain GeoJSON. The ability to define an area in https://geojson.io, for example, and then simply copy and paste it would make things much easier for users.
easbar commentedon Jan 26, 2023
Custom areas from files in the
custom_areas.directoryare now automatically available in all custom profiles: #2725