open-sdg / open-sdg

A platform for collecting and disseminating data for the Sustainable Development Goal global indicators.
https://open-sdg.org
MIT License
62 stars 74 forks source link

Expand docs for min and max zoom config options #1213

Closed WohnungNDS closed 2 years ago

WohnungNDS commented 3 years ago

Please complete the following information Data_repo Geojsonfile1 : NI_Kurz_diss.geojson Geojsonfile2: world_custom.geojson

Data or metadata issue: Data/Map/GeoJson Input format: CSV, Geojson

Describe the bug I have two different geojson files in my datarepo. geojsonfile1 covers the administrative local boundaries of lower saxony, geojsonfile2 covers the boundaries off all states over the world.

The idea is to show where people from all over the world come to lower saxony. eg 1234 from Poland 1222 from Turkey tbc

I add in my data_config file this:

map_layers:
  - geojson_file: NI_Kurz_diss.geojson
    name_property: GEN
    id_property: AGS
    output_subfolder: maps
    filename_prefix: indicator_
    exclude_columns: ['Gebietseinheit']
  - geojson_file: world_custom.geojson
    name_property: name_long
    id_property: LAGS
    output_subfolder: maps
    filename_prefix: indicator_

And added some test data to indicator Data 4.1.3

The map is shown more ore less correctly as you can see here

But now the other maps eg in indicator 1.1.1 contains no boundaries an also no data. There should be shown boundaries from Geojsonfile1 and data form indicator 1.1.1

Do I have to do changes in my site _config file too? Any Ideas?

WohnungNDS commented 3 years ago

It works (more or less)!

I added another layer in the site_config.yml

`map_layers:

The subfolder under 'geojson' in the data repository holding the GeoJSON files:

subfolder: maps
# The label to use in the "Download GeoJSON" button:
label: indicator.map
# The minimum zoom at which this layer should be visible.
min_zoom: 0
# The maximum zoom at which this layer should be visible.
max_zoom: 20
# Whether or not these boundaries should display statically on lower layers.
staticBorders: false

-

The subfolder under 'geojson' in the data repository holding the GeoJSON files:

subfolder: worldmap
# The label to use in the "Download GeoJSON" button:
label: indicator.map
# The minimum zoom at which this layer should be visible.
min_zoom: 0
# The maximum zoom at which this layer should be visible.
max_zoom: 20
# Whether or not these boundaries should display statically on lower layers.
staticBorders: false

`

But somethin is wrong with the zoom as you can see here

It is a world map. I want to show from which country people come to lower syxony.....

LucyGwilliamAdmin commented 3 years ago

@WohnungNDS I think you need to change the value of minZoom here: https://github.com/WohnungNDS/IM_Site/blob/develop/_config.yml#L178

However this will change site-wide

WohnungNDS commented 3 years ago

Thank you, @LucyGwilliamAdmin It works, as you can see here. The other Indicator e.g. here still has the right zoom. To me it is not clear where I have to adjust the zoom. In the map_options or for each layer in the map_layer

Additionaly I think I have to try different values for the minZoom

LucyGwilliamAdmin commented 3 years ago

No problem @WohnungNDS

For minZoom and maxZoom under map_options, that controls the total minimum/maximum zoom, no matter what layer is displayed

min_zoom and max_zoom under map_layers, tells the map what layer to show.

For example if you have

map_options:
  minZoom: 0
  maxZoom: 10

you may want:

map_layers:
-  subfolder: maps
    label: indicator.map
    min_zoom: 6
    max_zoom: 10
    staticBorders: false
-  subfolder: worldmap
    label: indicator.map
    min_zoom: 0
    max_zoom: 5
    staticBorders: false

This would create a nested zoom functionality where if data for both layers is available on an indicator, the 'worldmap' layer would show when zoomed out to the max and until you zoom in 6 times. Once you zoom in 6 times or more, the 'maps' layer would show until you get to zoom 10. Once you get to zoom 10 you won't be able to zoom in any more.

Note: all min_zooms should be greater than minZoom and all max_zooms should be less than maxZoom

WohnungNDS commented 3 years ago

@LucyGwilliamAdmin it works! But there is another download button under my map as you can see here

image

LucyGwilliamAdmin commented 3 years ago

@WohnungNDS I think it's because you are using two different geojson/map layers within the indicator. See how it's the same in this UK indicator: https://sdgdata.gov.uk/3-a-1/.

I'm not sure why they both say Karte though

WohnungNDS commented 3 years ago

@LucyGwilliamAdmin Thank you I have fixed this.... But there are more promlems with my geojson files. to me it is not clear how SDG decides which Goejson file schould be used..... Sometimes I get Errors like this.... But I have no idea what this error means

File "/opt/hostedtoolcache/Python/3.7.10/x64/lib/python3.7/site-packages/sdg/outputs/OutputGeoJson.py", line 148, in <listcomp> disaggregations = [self.clean_disaggregations(disaggregation) for disaggregation in disaggregations] File "/opt/hostedtoolcache/Python/3.7.10/x64/lib/python3.7/site-packages/sdg/outputs/OutputGeoJson.py", line 214, in clean_disaggregations del disaggregations[self.id_column] KeyError: 'GeoCode' Error: Process completed with exit code 1.

WohnungNDS commented 3 years ago

@LucyGwilliamAdmin In this indicator this geojson is used the id property is "LAGS"

in this indicator I want to use this Geojson and use the id property "staat_schlues"

If I change my config_data in this line https://github.com/WohnungNDS/IM_Data/blob/29222f4487b1255f64648065eeb05f25881181c4/config_data.yml#L121 to id_property: staat_schlues I get the mentioned error above

WohnungNDS commented 3 years ago

@LucyGwilliamAdmin @brockfanning

Hello,

three questions before I start a new try add two geojson filfes to have different maps:

1) Where do I have to store my geojson files. All in the same folder or is it better to have one folder for each geojson? 2) are there any restrictions for the file names? 3) and has the output_subfolder: maps to be different from my folder holding my geojson file?

Thank you

LucyGwilliamAdmin commented 3 years ago

Hi @WohnungNDS

  1. The geojson stores can be stored anywhere, even outside of Github repo. See UK example where we point at URL: https://github.com/ONSdigital/sdg-data/blob/develop/config_data.yml#L55
  2. No restrictions to the names that I know of
  3. I don't think output_subfolder necessarily needs to be different from the folder holding your geojson file but each of the layers should have distinct names. Again take a look at UK example to see how we did it.
LucyGwilliamAdmin commented 2 years ago

@WohnungNDS is this one still needed or have you resolved your issue?

WohnungNDS commented 2 years ago

@LucyGwilliamAdmin It works fine... But the zoom values are different from the documentation...

No problem @WohnungNDS

For minZoom and maxZoom under map_options, that controls the total minimum/maximum zoom, no matter what layer is displayed

min_zoom and max_zoom under map_layers, tells the map what layer to show.

For example if you have

map_options: minZoom: 0 maxZoom: 10 you may want:

map_layers:

Note: all min_zooms should be greater than minZoom and all max_zooms should be less than maxZoom

Originally posted by @LucyGwilliamAdmin in #1213 (comment)

My current settings are:

`map_layers:

find my config file here

LucyGwilliamAdmin commented 2 years ago

@WohnungNDS so is it all resolved then?

I do have one comment from looking at your config - your min_zooms are less than your minZoom and your max_zooms are greater than your maxZoom

WohnungNDS commented 2 years ago

@LucyGwilliamAdmin Yes, that's right, but the only way it works....At the moment I haven't time to get in this... Perhaps we leave it open and i will get back in this ina couple of weeks...

LucyGwilliamAdmin commented 2 years ago

Oh right, that's strange - something definitely sounds off.

brockfanning commented 2 years ago

@WohnungNDS In reading through this issue I'm having a hard time understanding. Would it be possible for you to summarize with answers to these questions?

  1. What is the behavior that you're expecting?
  2. What is the behavior that you're seeing? (with a link)
christoph-LSN commented 2 years ago

@brockfanning

this issue is more or less solved. The map is working as expected. Tho only thing is, that in my _site_config.yml the min and max zoom values are different from the values recommended in the documentaiton

brockfanning commented 2 years ago

@christoph-LSN Sorry I missed this. To be clear, the documentation is only showing defaults/examples, and not necessarily recommendations. I do think we need better names for those settings. The 'minZoom' and 'maxZoom' under 'map_options' are named OK, but under 'map_layers' they probably should be 'visible_above' and 'visible_below' or something like that.

Do you think the documentation needs any changes or additions?

christoph-LSN commented 2 years ago

@brockfanning

probably should be 'visible_above' and 'visible_below' or something like that.

Yes, this may be a good idea...