Closed cypressf closed 1 year ago
We are going to use all of asia for now. The data we have for russia is for all of russia right now, not for all of rusia only in asia, but kilian will split out the data for the asian portion of rusia.
I'm looking to find some geojson files for africa and asia
Going to use the data behind https://observablehq.com/@fil/map-of-africa or https://observablehq.com/@djr4/gdp-per-capita-ppp-africa-vs-serbia for the map of africa. Potentially could use the same data with a different filter and projection for the map of asia.
whatever map file I use, I plan to use the iso-3 format for countries
I'm going to use https://github.com/topojson/world-atlas for my map. I'll find a way to filter by region if we want to show only africa and asia. For now, I'm going to experiment with it and see if I can get some data displaying on a country-level globally.
country
tableColumn | Type | Nullable |
---|---|---|
id |
int2 | NO |
name |
text | NO |
primary key: id
county_data
table to usa_county_data
county
table to usa_county
state
table to usa_state
country_data
tableColumn | Type | Nullable | Foreign key |
---|---|---|---|
dataset |
int4 | NO | dataset(id) |
source |
int4 | NO | data_source(id) |
start_date |
date | NO | |
end_date |
date | NO | |
country_id |
int2 | NO | country(id) |
value |
float8 | YES |
geography_type
tableColumn | Type | Nullable |
---|---|---|
id |
int4 | NO |
name |
varchar(100) | NO |
[x] insert (1, "usa-county"), (2, "country")
[x] Modify map_visualization
table, add column
Column | Type | Nullable | Foreign key |
---|---|---|---|
geography_type |
int4 | NO | geography_type(id) |
[x] Assign geography type "county" (1
) to all existing maps
[x] Modify data_category
table, add column
Column | Type | Nullable | Foreign key |
---|---|---|---|
geography_type |
int4 | NO | geography_type(id) |
1
) to all existing data categoriescountry_data_controller
#[get("/country-data/{id}")]
fn get(id,{source, start_date, end_date})
data_controller
to usa_county_data_controller
Similarly add and rename daos, and models.
Note: instead I'm putting everything inside the same data_controller.rs
geography_type
is country
, show world countries map and request data from /api/country-data
, otherwise show the usa counties map and request data from /api/usa-county-data
country
geography type, if usa tab is selected, only show tabs that are part of the usa-county
geography type.world-atlas uses ISO 3166-1 numeric 3-digit country codes instead of the iso-3 alphabetical format. Let's use those in the database and for all data as well. Perhaps I could add a column for alphabetical format if needed, but I'll keep them numeric for now.
there are 249 countries in kilian's dataset
There are 174 countries in the world map I'm using. It's worth examining which countries are missing between Kilian's datasets and my world map to see if we can show a more complete picture. Is this because the world map is outdated? Because it's missing labels? Because Kilian's dataset is outdated?
Based on my test (https://github.com/cypressf/map-data-cleaning/commit/8aa2f6abf28535a2344e133add956a32a7a81b43), the following 75 countries are missing from the map:
๐ต๐ณ Pitcairn ๐ธ๐ญ Saint Helena, Ascension and Tristan da Cunha ๐ฒ๐ถ Martinique ๐ฐ๐ฒ Comoros ๐ฏ๐ช Jersey ๐ป๐ฌ Virgin Islands, British ๐ฒ๐บ Mauritius ๐ธ๐ฏ Svalbard and Jan Mayen ๐จ๐ป Cabo Verde ๐ฒ๐ด Macao ๐จ๐ฐ Cook Islands ๐ง๐ฒ Bermuda ๐ต๐ผ Palau ๐ป๐ฎ Virgin Islands, U.S. ๐น๐ฐ Tokelau ๐ฆ๐ธ American Samoa ๐ฒ๐ซ Saint Martin (French part) ๐ฌ๐บ Guam ๐พ๐น Mayotte ๐จ๐ผ Curaรงao ๐ญ๐ฐ Hong Kong ๐ธ๐ฒ San Marino ๐ง๐ง Barbados ๐ฒ๐จ Monaco ๐ผ๐ซ Wallis and Futuna ๐น๐ด Tonga ๐ฆ๐ฌ Antigua and Barbuda ๐จ๐ฝ Christmas Island ๐ญ๐ฒ Heard Island and McDonald Islands ๐ซ๐ด Faroe Islands ๐ฌ๐ธ South Georgia and the South Sandwich Islands ๐ฐ๐พ Cayman Islands ๐ผ๐ธ Samoa ๐ต๐ฒ Saint Pierre and Miquelon ๐ซ๐ฒ Micronesia, Federated States of ๐ฒ๐ป Maldives ๐ฐ๐ฎ Kiribati ๐ณ๐ซ Norfolk Island ๐ง๐ป Bouvet Island ๐ฐ๐ณ Saint Kitts and Nevis ๐ฌ๐ซ French Guiana ๐ต๐ซ French Polynesia ๐น๐ป Tuvalu ๐ธ๐น Sao Tome and Principe ๐ฒ๐ญ Marshall Islands ๐ป๐จ Saint Vincent and the Grenadines ๐ณ๐บ Niue ๐ฌ๐ฌ Guernsey ๐ท๐ช Rรฉunion ๐ฎ๐ฒ Isle of Man ๐จ๐จ Cocos (Keeling) Islands ๐ฉ๐ฒ Dominica ๐ง๐ถ Bonaire, Sint Eustatius and Saba ๐ฒ๐น Malta ๐ฌ๐ฎ Gibraltar ๐ฎ๐ด British Indian Ocean Territory ๐บ๐ฒ United States Minor Outlying Islands ๐ฆ๐ผ Aruba ๐ณ๐ท Nauru ๐ฌ๐ฉ Grenada ๐ฌ๐ต Guadeloupe ๐ธ๐ฝ Sint Maarten (Dutch part) ๐ฑ๐จ Saint Lucia ๐ง๐ญ Bahrain ๐ฒ๐ต Northern Mariana Islands ๐ฆ๐ฎ Anguilla ๐ธ๐จ Seychelles ๐ฑ๐ฎ Liechtenstein ๐ฒ๐ธ Montserrat ๐ฆ๐ฝ ร land Islands ๐ธ๐ฌ Singapore ๐ป๐ฆ Holy See (Vatican City State) ๐น๐จ Turks and Caicos Islands ๐ง๐ฑ Saint Barthรฉlemy ๐ฆ๐ฉ Andorra
Many of the countries that are missing are possibly map units (smaller units than countries) https://www.naturalearthdata.com/downloads/10m-cultural-vectors/10m-admin-0-details/
For now I'm going to add the sovereign nations in the map to the database, and ignore the countries listed above. Next, I'll investigate how to add them to the map.
map_visualization
s with param geography_type
(values: 1: usa-county
,2: country
). If geography_type
is set to neither or both it will include all map_visualization
s, but if it is set to one or the other, it will only return items of that type.geography_type
param will be set by a tab or a radio toggle for now. It should persist in the redux store, but doesn't need to appear in the url for now.We're planning on sticking with ISO standard 3166-1 numeric country codes as of 2022.
I'm resuming work on this now that I've released county report cards
I'm running into an issue where Table<MapVisualization>.all(true, None)
returns duplicate map visualizations and doesn't return any that are not in a tab. The SQL query needs experimenting with and I need to write some tests for it.
Fixed that issue!
Now I'm seeing a crash when I toggle to Global view. I'll investigate tomorrow.
It was crashing because there were no world maps for the selected tab when I toggled from USA to world. The solution is twofold: pass an empty object instead of undefined as the state to components that expect map visualizations, and automatically filter tabs out if they are empty, and select the first non-empty tab.
I had to modify the data processor so it could handle country codes because it had assumed that all data was index by usa-county SIPS code: https://github.com/mit-jp/climate-risk-map/commit/aacee71f7bb1d4366397ffe4aa0479931adfc9e7
It might make more sense to add geography_type
to dataset
instead of map_visualization
because each dataset is inherently associated with either the world or the USA. Someone can't modify a map visualization to be of the World if geographic region of the dataset is the USA
/editor
, the map selection list selects the first map, even if you're viewing a map lower in the listIt's looking like it'd be easier to use one table for all data, and make the primary key a composite of the id
column and a geography_type
column. That way, we wouldn't have to make a separate queries for every geography type. Instead, it would be one query, with the geography type specified in the query. For state-filters, however, we'd need to filter by id prefix since we could no longer have the id in the query itself.
Okay. Global maps are ready to go. I just need to add data.