mirror of
https://github.com/DOI-DO/j40-cejst-2.git
synced 2025-07-26 01:41:16 -07:00
Fix on large AK tracts that are off screen (#1740)
* Change low to high transition and global zoom - change the low to high transition from 7 to 5. This can not go any lower as high tiles on AWS only go to zoom level 5 - reduce the zoom level globally on all census tracts * Remove geolocation from feature flag - geolocation is now available to all * Add python notebook that sorts all tracts by area - add a column of the required zoom level for the tract to be fully contained in the viewport * Place geolocation back to behind a feature flag * Differentiate zoom levels b/w shortcuts and tracts
This commit is contained in:
parent
a5a4c31bb0
commit
eb3004c0d5
3 changed files with 518 additions and 49 deletions
|
@ -136,6 +136,7 @@ const J40Map = ({location}: IJ40Interface) => {
|
||||||
const filter = useMemo(() => ['in', constants.GEOID_PROPERTY, selectedFeatureId], [selectedFeature]);
|
const filter = useMemo(() => ['in', constants.GEOID_PROPERTY, selectedFeatureId], [selectedFeature]);
|
||||||
|
|
||||||
const zoomLatLngHash = mapRef.current?.getMap()._hash._getCurrentHash();
|
const zoomLatLngHash = mapRef.current?.getMap()._hash._getCurrentHash();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function will return the bounding box of the current map. Comment in when needed.
|
* This function will return the bounding box of the current map. Comment in when needed.
|
||||||
* {
|
* {
|
||||||
|
@ -169,28 +170,28 @@ const J40Map = ({location}: IJ40Interface) => {
|
||||||
|
|
||||||
switch (buttonID) {
|
switch (buttonID) {
|
||||||
case '48':
|
case '48':
|
||||||
goToPlace(constants.LOWER_48_BOUNDS);
|
goToPlace(constants.LOWER_48_BOUNDS, true);
|
||||||
break;
|
break;
|
||||||
case 'AK':
|
case 'AK':
|
||||||
goToPlace(constants.ALASKA_BOUNDS);
|
goToPlace(constants.ALASKA_BOUNDS, true);
|
||||||
break;
|
break;
|
||||||
case 'HI':
|
case 'HI':
|
||||||
goToPlace(constants.HAWAII_BOUNDS);
|
goToPlace(constants.HAWAII_BOUNDS, true);
|
||||||
break;
|
break;
|
||||||
case 'PR':
|
case 'PR':
|
||||||
goToPlace(constants.PUERTO_RICO_BOUNDS);
|
goToPlace(constants.PUERTO_RICO_BOUNDS, true);
|
||||||
break;
|
break;
|
||||||
case 'GU':
|
case 'GU':
|
||||||
goToPlace(constants.GUAM_BOUNDS);
|
goToPlace(constants.GUAM_BOUNDS, true);
|
||||||
break;
|
break;
|
||||||
case 'AS':
|
case 'AS':
|
||||||
goToPlace(constants.AMERICAN_SAMOA_BOUNDS);
|
goToPlace(constants.AMERICAN_SAMOA_BOUNDS, true);
|
||||||
break;
|
break;
|
||||||
case 'MP':
|
case 'MP':
|
||||||
goToPlace(constants.MARIANA_ISLAND_BOUNDS);
|
goToPlace(constants.MARIANA_ISLAND_BOUNDS, true);
|
||||||
break;
|
break;
|
||||||
case 'VI':
|
case 'VI':
|
||||||
goToPlace(constants.US_VIRGIN_ISLANDS_BOUNDS);
|
goToPlace(constants.US_VIRGIN_ISLANDS_BOUNDS, true);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -200,10 +201,32 @@ const J40Map = ({location}: IJ40Interface) => {
|
||||||
// This else clause will fire when the ID is null or empty. This is the case where the map is clicked
|
// This else clause will fire when the ID is null or empty. This is the case where the map is clicked
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const feature = event.features && event.features[0];
|
const feature = event.features && event.features[0];
|
||||||
console.log(feature);
|
|
||||||
if (feature) {
|
if (feature) {
|
||||||
|
// Get the current selected feature's bounding box:
|
||||||
const [minLng, minLat, maxLng, maxLat] = bbox(feature);
|
const [minLng, minLat, maxLng, maxLat] = bbox(feature);
|
||||||
|
|
||||||
|
// Set the selectedFeature ID
|
||||||
|
if (feature.id !== selectedFeatureId) {
|
||||||
|
setSelectedFeature(feature);
|
||||||
|
} else {
|
||||||
|
setSelectedFeature(undefined);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Go to the newly selected feature
|
||||||
|
goToPlace([
|
||||||
|
[minLng, minLat],
|
||||||
|
[maxLng, maxLat],
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The following logic is used for the popup for the fullscreen feature
|
||||||
|
*/
|
||||||
|
// Create a new viewport using the current viewport dimnesions:
|
||||||
const newViewPort = new WebMercatorViewport({height: viewport.height!, width: viewport.width!});
|
const newViewPort = new WebMercatorViewport({height: viewport.height!, width: viewport.width!});
|
||||||
|
|
||||||
|
// Fit the viewport to the new bounds and return a long, lat and zoom:
|
||||||
const {longitude, latitude, zoom} = newViewPort.fitBounds(
|
const {longitude, latitude, zoom} = newViewPort.fitBounds(
|
||||||
[
|
[
|
||||||
[minLng, minLat],
|
[minLng, minLat],
|
||||||
|
@ -213,22 +236,21 @@ const J40Map = ({location}: IJ40Interface) => {
|
||||||
padding: 40,
|
padding: 40,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if (feature.id !== selectedFeatureId) {
|
|
||||||
setSelectedFeature(feature);
|
// Save the popupInfo
|
||||||
} else {
|
|
||||||
setSelectedFeature(undefined);
|
|
||||||
}
|
|
||||||
const popupInfo = {
|
const popupInfo = {
|
||||||
longitude: longitude,
|
longitude: longitude,
|
||||||
latitude: latitude,
|
latitude: latitude,
|
||||||
zoom: zoom,
|
zoom: zoom,
|
||||||
properties: feature.properties,
|
properties: feature.properties,
|
||||||
};
|
};
|
||||||
goToPlace([
|
|
||||||
[minLng, minLat],
|
// Update the DetailedView state variable with the new popupInfo object:
|
||||||
[maxLng, maxLat],
|
|
||||||
]);
|
|
||||||
setDetailViewData(popupInfo);
|
setDetailViewData(popupInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* End Fullscreen feature specific logic
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -242,17 +264,44 @@ const J40Map = ({location}: IJ40Interface) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const goToPlace = (bounds: LngLatBoundsLike ) => {
|
/**
|
||||||
const {longitude, latitude, zoom} = new WebMercatorViewport({height: viewport.height!, width: viewport.width!})
|
* This function will move the map (with easing) to the given lat/long bounds.
|
||||||
.fitBounds(bounds as [[number, number], [number, number]], {
|
*
|
||||||
padding: 20,
|
* When a user clicks on a tracts vs a territory button, the zoom level returned by the fitBounds
|
||||||
offset: [0, -100],
|
* function differ. Given that we want to handle the zoom differently depending on these two cases, we
|
||||||
});
|
* introduce a boolean, isTerritory that will allow the zoom level to be set depending on what the user
|
||||||
|
* is interacting with, namely a tract vs a territory button.
|
||||||
|
*
|
||||||
|
* @param {LngLatBoundsLike} bounds
|
||||||
|
* @param {boolean} isTerritory
|
||||||
|
*/
|
||||||
|
const goToPlace = (bounds: LngLatBoundsLike, isTerritory = false ) => {
|
||||||
|
const newViewPort = new WebMercatorViewport({height: viewport.height!, width: viewport.width!});
|
||||||
|
const {longitude, latitude, zoom} = newViewPort.fitBounds(
|
||||||
|
bounds as [[number, number], [number, number]], {
|
||||||
|
// padding: 200, // removing padding and offset in favor of a zoom offset below
|
||||||
|
// offset: [0, -100],
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When some tracts are selected, they end up too far zoomed in, causing some census tracts to
|
||||||
|
* only show a portion of the tract in the viewport. We reduce the zoom level by 1 to allow
|
||||||
|
* more space around the selected tract.
|
||||||
|
*
|
||||||
|
* Given that the high zoom tiles only go to zoom level 5, if the corrected zoom level (zoom - 1) is
|
||||||
|
* less than MIN_ZOOM_FEATURE_BORDER, then we floor the zoom to MIN_ZOOM_FEATURE_BORDER + .1 (which
|
||||||
|
* is 5.1 as of this comment)
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line max-len
|
||||||
|
const featureSelectionZoomLevel = (zoom - 1) < constants.GLOBAL_MIN_ZOOM_FEATURE_BORDER + .1 ?
|
||||||
|
constants.GLOBAL_MIN_ZOOM_FEATURE_BORDER :
|
||||||
|
zoom - 1;
|
||||||
|
|
||||||
setViewport({
|
setViewport({
|
||||||
...viewport,
|
...viewport,
|
||||||
longitude,
|
longitude,
|
||||||
latitude,
|
latitude,
|
||||||
zoom,
|
zoom: isTerritory ? zoom : featureSelectionZoomLevel,
|
||||||
transitionDuration: 1000,
|
transitionDuration: 1000,
|
||||||
transitionInterpolator: new FlyToInterpolator(),
|
transitionInterpolator: new FlyToInterpolator(),
|
||||||
transitionEasing: d3.easeCubic,
|
transitionEasing: d3.easeCubic,
|
||||||
|
@ -434,7 +483,26 @@ const J40Map = ({location}: IJ40Interface) => {
|
||||||
/>
|
/>
|
||||||
</Source>
|
</Source>
|
||||||
|
|
||||||
{/* Enable fullscreen behind a feature flag */}
|
{/* This will add the navigation controls of the zoom in and zoom out buttons */}
|
||||||
|
{ windowWidth > constants.USWDS_BREAKPOINTS.MOBILE_LG && <NavigationControl
|
||||||
|
showCompass={false}
|
||||||
|
className={styles.navigationControl}
|
||||||
|
/> }
|
||||||
|
|
||||||
|
{/* This will show shortcut buttons to pan/zoom to US territories */}
|
||||||
|
<TerritoryFocusControl onClick={onClick}/>
|
||||||
|
|
||||||
|
{/* This places Geolocation behind a feature flag */}
|
||||||
|
{'gl' in flags ? <GeolocateControl
|
||||||
|
className={styles.geolocateControl}
|
||||||
|
positionOptions={{enableHighAccuracy: true}}
|
||||||
|
onGeolocate={onGeolocate}
|
||||||
|
// @ts-ignore
|
||||||
|
onClick={onClickGeolocate}
|
||||||
|
/> : ''}
|
||||||
|
{geolocationInProgress ? <div>Geolocation in progress...</div> : ''}
|
||||||
|
|
||||||
|
{/* Enable fullscreen pop-up behind a feature flag */}
|
||||||
{('fs' in flags && detailViewData && !transitionInProgress) && (
|
{('fs' in flags && detailViewData && !transitionInProgress) && (
|
||||||
<Popup
|
<Popup
|
||||||
className={styles.j40Popup}
|
className={styles.j40Popup}
|
||||||
|
@ -449,26 +517,6 @@ const J40Map = ({location}: IJ40Interface) => {
|
||||||
<AreaDetail properties={detailViewData.properties} hash={zoomLatLngHash}/>
|
<AreaDetail properties={detailViewData.properties} hash={zoomLatLngHash}/>
|
||||||
</Popup>
|
</Popup>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{/* This will add the navigation controls of the zoom in and zoom out buttons */}
|
|
||||||
{ windowWidth > constants.USWDS_BREAKPOINTS.MOBILE_LG && <NavigationControl
|
|
||||||
showCompass={false}
|
|
||||||
className={styles.navigationControl}
|
|
||||||
/> }
|
|
||||||
|
|
||||||
{/* This places Geolocation behind a feature flag */}
|
|
||||||
{'gl' in flags ? <GeolocateControl
|
|
||||||
className={styles.geolocateControl}
|
|
||||||
positionOptions={{enableHighAccuracy: true}}
|
|
||||||
onGeolocate={onGeolocate}
|
|
||||||
// @ts-ignore
|
|
||||||
onClick={onClickGeolocate}
|
|
||||||
/> : ''}
|
|
||||||
{geolocationInProgress ? <div>Geolocation in progress...</div> : ''}
|
|
||||||
|
|
||||||
{/* This will show shortcut buttons to pan/zoom to US territories */}
|
|
||||||
<TerritoryFocusControl onClick={onClick}/>
|
|
||||||
|
|
||||||
{'fs' in flags ? <FullscreenControl className={styles.fullscreenControl}/> :'' }
|
{'fs' in flags ? <FullscreenControl className={styles.fullscreenControl}/> :'' }
|
||||||
|
|
||||||
</ReactMapGL>
|
</ReactMapGL>
|
||||||
|
|
|
@ -204,11 +204,14 @@ export const SCORE_PROPERTY_HIGH = 'SM_PFS';
|
||||||
// Zoom
|
// Zoom
|
||||||
export const GLOBAL_MIN_ZOOM = 3;
|
export const GLOBAL_MIN_ZOOM = 3;
|
||||||
export const GLOBAL_MAX_ZOOM = 22;
|
export const GLOBAL_MAX_ZOOM = 22;
|
||||||
|
|
||||||
export const GLOBAL_MIN_ZOOM_LOW = 3;
|
export const GLOBAL_MIN_ZOOM_LOW = 3;
|
||||||
export const GLOBAL_MAX_ZOOM_LOW = 7;
|
export const GLOBAL_MAX_ZOOM_LOW = 5;
|
||||||
export const GLOBAL_MIN_ZOOM_HIGH = 7;
|
|
||||||
|
export const GLOBAL_MIN_ZOOM_HIGH = 5;
|
||||||
export const GLOBAL_MAX_ZOOM_HIGH = 11;
|
export const GLOBAL_MAX_ZOOM_HIGH = 11;
|
||||||
export const GLOBAL_MIN_ZOOM_FEATURE_BORDER = 7;
|
|
||||||
|
export const GLOBAL_MIN_ZOOM_FEATURE_BORDER = 5;
|
||||||
export const GLOBAL_MAX_ZOOM_FEATURE_BORDER = 22;
|
export const GLOBAL_MAX_ZOOM_FEATURE_BORDER = 22;
|
||||||
|
|
||||||
// Opacity
|
// Opacity
|
||||||
|
|
418
data/data-pipeline/data_pipeline/ipython/TractArea.ipynb
Normal file
418
data/data-pipeline/data_pipeline/ipython/TractArea.ipynb
Normal file
|
@ -0,0 +1,418 @@
|
||||||
|
{
|
||||||
|
"cells": [
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 54,
|
||||||
|
"id": "df048f08",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"import geopandas as gpd\n",
|
||||||
|
"import pathlib"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 55,
|
||||||
|
"id": "62366f7d",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"lowJson = pathlib.Path() / 'usa-low.json'\n",
|
||||||
|
"assert lowJson.exists()\n",
|
||||||
|
"highJson = pathlib.Path() / 'usa-high.json'\n",
|
||||||
|
"assert highJson.exists()"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 50,
|
||||||
|
"id": "4077ed78",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"gdf = gpd.read_file(highJson)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 56,
|
||||||
|
"id": "d4abfc64",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": [
|
||||||
|
"gdf['area'] = gdf.apply(lambda row : gpd.GeoSeries(row['geometry']).area, axis = 1)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "markdown",
|
||||||
|
"id": "5077d9ef",
|
||||||
|
"metadata": {},
|
||||||
|
"source": [
|
||||||
|
"Add `zlfc` = *zoom level full containment*, This field will indicate the maximum zoom level the user can go up to while still keeping the entire tract in view. Below, we sample a few tracts to get an idea of the relationship between zoom level and area"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 89,
|
||||||
|
"id": "a1234574",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/html": [
|
||||||
|
"<div>\n",
|
||||||
|
"<style scoped>\n",
|
||||||
|
" .dataframe tbody tr th:only-of-type {\n",
|
||||||
|
" vertical-align: middle;\n",
|
||||||
|
" }\n",
|
||||||
|
"\n",
|
||||||
|
" .dataframe tbody tr th {\n",
|
||||||
|
" vertical-align: top;\n",
|
||||||
|
" }\n",
|
||||||
|
"\n",
|
||||||
|
" .dataframe thead th {\n",
|
||||||
|
" text-align: right;\n",
|
||||||
|
" }\n",
|
||||||
|
"</style>\n",
|
||||||
|
"<table border=\"1\" class=\"dataframe\">\n",
|
||||||
|
" <thead>\n",
|
||||||
|
" <tr style=\"text-align: right;\">\n",
|
||||||
|
" <th></th>\n",
|
||||||
|
" <th>GEOID10</th>\n",
|
||||||
|
" <th>SF</th>\n",
|
||||||
|
" <th>CF</th>\n",
|
||||||
|
" <th>area</th>\n",
|
||||||
|
" <th>zlfc</th>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" </thead>\n",
|
||||||
|
" <tbody>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9846</th>\n",
|
||||||
|
" <td>02185000200</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>North Slope Borough</td>\n",
|
||||||
|
" <td>53.323702</td>\n",
|
||||||
|
" <td>4.45</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9937</th>\n",
|
||||||
|
" <td>02290000100</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Yukon-Koyukuk Census Area</td>\n",
|
||||||
|
" <td>21.653154</td>\n",
|
||||||
|
" <td>5.50</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9857</th>\n",
|
||||||
|
" <td>02188000100</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Northwest Arctic Borough</td>\n",
|
||||||
|
" <td>21.188159</td>\n",
|
||||||
|
" <td>5.50</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9935</th>\n",
|
||||||
|
" <td>02290000200</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Yukon-Koyukuk Census Area</td>\n",
|
||||||
|
" <td>20.744770</td>\n",
|
||||||
|
" <td>5.38</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9934</th>\n",
|
||||||
|
" <td>02290000300</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Yukon-Koyukuk Census Area</td>\n",
|
||||||
|
" <td>17.140826</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9936</th>\n",
|
||||||
|
" <td>02290000400</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Yukon-Koyukuk Census Area</td>\n",
|
||||||
|
" <td>14.687448</td>\n",
|
||||||
|
" <td>5.77</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9893</th>\n",
|
||||||
|
" <td>02180000100</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Nome Census Area</td>\n",
|
||||||
|
" <td>13.377817</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9847</th>\n",
|
||||||
|
" <td>02164000100</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Lake and Peninsula Borough</td>\n",
|
||||||
|
" <td>13.061644</td>\n",
|
||||||
|
" <td>5.33</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9918</th>\n",
|
||||||
|
" <td>02261000100</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Valdez-Cordova Census Area</td>\n",
|
||||||
|
" <td>11.118835</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9945</th>\n",
|
||||||
|
" <td>02050000100</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Bethel Census Area</td>\n",
|
||||||
|
" <td>10.951888</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9841</th>\n",
|
||||||
|
" <td>02270000100</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Wade Hampton Census Area</td>\n",
|
||||||
|
" <td>8.771806</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9839</th>\n",
|
||||||
|
" <td>02240000100</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Southeast Fairbanks Census Area</td>\n",
|
||||||
|
" <td>8.613690</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9843</th>\n",
|
||||||
|
" <td>02070000100</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Dillingham Census Area</td>\n",
|
||||||
|
" <td>8.575307</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9947</th>\n",
|
||||||
|
" <td>02050000300</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Bethel Census Area</td>\n",
|
||||||
|
" <td>8.408040</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9899</th>\n",
|
||||||
|
" <td>02170000101</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Matanuska-Susitna Borough</td>\n",
|
||||||
|
" <td>6.480444</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9944</th>\n",
|
||||||
|
" <td>02068000100</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Denali Borough</td>\n",
|
||||||
|
" <td>5.997236</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9836</th>\n",
|
||||||
|
" <td>02013000100</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Aleutians East Borough</td>\n",
|
||||||
|
" <td>5.487726</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9921</th>\n",
|
||||||
|
" <td>02122000100</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Kenai Peninsula Borough</td>\n",
|
||||||
|
" <td>4.831831</td>\n",
|
||||||
|
" <td>6.10</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9851</th>\n",
|
||||||
|
" <td>02150000100</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Kodiak Island Borough</td>\n",
|
||||||
|
" <td>4.664009</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9850</th>\n",
|
||||||
|
" <td>02105000300</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Hoonah-Angoon Census Area</td>\n",
|
||||||
|
" <td>4.305716</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9838</th>\n",
|
||||||
|
" <td>02016000100</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Aleutians West Census Area</td>\n",
|
||||||
|
" <td>4.053520</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9917</th>\n",
|
||||||
|
" <td>02282000100</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Yakutat City and Borough</td>\n",
|
||||||
|
" <td>3.926182</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9920</th>\n",
|
||||||
|
" <td>02261000300</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Valdez-Cordova Census Area</td>\n",
|
||||||
|
" <td>3.285482</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9840</th>\n",
|
||||||
|
" <td>02240000400</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Southeast Fairbanks Census Area</td>\n",
|
||||||
|
" <td>3.233961</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9919</th>\n",
|
||||||
|
" <td>02261000200</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Valdez-Cordova Census Area</td>\n",
|
||||||
|
" <td>3.156317</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>10354</th>\n",
|
||||||
|
" <td>41045970900</td>\n",
|
||||||
|
" <td>Oregon</td>\n",
|
||||||
|
" <td>Malheur County</td>\n",
|
||||||
|
" <td>2.731719</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9888</th>\n",
|
||||||
|
" <td>02198000100</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Prince of Wales-Hyder Census Area</td>\n",
|
||||||
|
" <td>2.606286</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>10212</th>\n",
|
||||||
|
" <td>41025960200</td>\n",
|
||||||
|
" <td>Oregon</td>\n",
|
||||||
|
" <td>Harney County</td>\n",
|
||||||
|
" <td>2.568943</td>\n",
|
||||||
|
" <td>7.08</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9844</th>\n",
|
||||||
|
" <td>02185000300</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>North Slope Borough</td>\n",
|
||||||
|
" <td>2.463165</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" <tr>\n",
|
||||||
|
" <th>9858</th>\n",
|
||||||
|
" <td>02130000100</td>\n",
|
||||||
|
" <td>Alaska</td>\n",
|
||||||
|
" <td>Ketchikan Gateway Borough</td>\n",
|
||||||
|
" <td>2.440051</td>\n",
|
||||||
|
" <td>0.00</td>\n",
|
||||||
|
" </tr>\n",
|
||||||
|
" </tbody>\n",
|
||||||
|
"</table>\n",
|
||||||
|
"</div>"
|
||||||
|
],
|
||||||
|
"text/plain": [
|
||||||
|
" GEOID10 SF CF area zlfc\n",
|
||||||
|
"9846 02185000200 Alaska North Slope Borough 53.323702 4.45\n",
|
||||||
|
"9937 02290000100 Alaska Yukon-Koyukuk Census Area 21.653154 5.50\n",
|
||||||
|
"9857 02188000100 Alaska Northwest Arctic Borough 21.188159 5.50\n",
|
||||||
|
"9935 02290000200 Alaska Yukon-Koyukuk Census Area 20.744770 5.38\n",
|
||||||
|
"9934 02290000300 Alaska Yukon-Koyukuk Census Area 17.140826 0.00\n",
|
||||||
|
"9936 02290000400 Alaska Yukon-Koyukuk Census Area 14.687448 5.77\n",
|
||||||
|
"9893 02180000100 Alaska Nome Census Area 13.377817 0.00\n",
|
||||||
|
"9847 02164000100 Alaska Lake and Peninsula Borough 13.061644 5.33\n",
|
||||||
|
"9918 02261000100 Alaska Valdez-Cordova Census Area 11.118835 0.00\n",
|
||||||
|
"9945 02050000100 Alaska Bethel Census Area 10.951888 0.00\n",
|
||||||
|
"9841 02270000100 Alaska Wade Hampton Census Area 8.771806 0.00\n",
|
||||||
|
"9839 02240000100 Alaska Southeast Fairbanks Census Area 8.613690 0.00\n",
|
||||||
|
"9843 02070000100 Alaska Dillingham Census Area 8.575307 0.00\n",
|
||||||
|
"9947 02050000300 Alaska Bethel Census Area 8.408040 0.00\n",
|
||||||
|
"9899 02170000101 Alaska Matanuska-Susitna Borough 6.480444 0.00\n",
|
||||||
|
"9944 02068000100 Alaska Denali Borough 5.997236 0.00\n",
|
||||||
|
"9836 02013000100 Alaska Aleutians East Borough 5.487726 0.00\n",
|
||||||
|
"9921 02122000100 Alaska Kenai Peninsula Borough 4.831831 6.10\n",
|
||||||
|
"9851 02150000100 Alaska Kodiak Island Borough 4.664009 0.00\n",
|
||||||
|
"9850 02105000300 Alaska Hoonah-Angoon Census Area 4.305716 0.00\n",
|
||||||
|
"9838 02016000100 Alaska Aleutians West Census Area 4.053520 0.00\n",
|
||||||
|
"9917 02282000100 Alaska Yakutat City and Borough 3.926182 0.00\n",
|
||||||
|
"9920 02261000300 Alaska Valdez-Cordova Census Area 3.285482 0.00\n",
|
||||||
|
"9840 02240000400 Alaska Southeast Fairbanks Census Area 3.233961 0.00\n",
|
||||||
|
"9919 02261000200 Alaska Valdez-Cordova Census Area 3.156317 0.00\n",
|
||||||
|
"10354 41045970900 Oregon Malheur County 2.731719 0.00\n",
|
||||||
|
"9888 02198000100 Alaska Prince of Wales-Hyder Census Area 2.606286 0.00\n",
|
||||||
|
"10212 41025960200 Oregon Harney County 2.568943 7.08\n",
|
||||||
|
"9844 02185000300 Alaska North Slope Borough 2.463165 0.00\n",
|
||||||
|
"9858 02130000100 Alaska Ketchikan Gateway Borough 2.440051 0.00"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 89,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"gdf['zlfc'] = 0\n",
|
||||||
|
"gdf.at[9846, 'zlfc'] = 4.45\n",
|
||||||
|
"gdf.at[10212, 'zlfc'] = 7.08\n",
|
||||||
|
"gdf.at[9937, 'zlfc'] = 5.5\n",
|
||||||
|
"gdf.at[9857, 'zlfc'] = 5.5\n",
|
||||||
|
"gdf.at[9935, 'zlfc'] = 5.38\n",
|
||||||
|
"gdf.at[9936, 'zlfc'] = 5.77\n",
|
||||||
|
"gdf.at[9921, 'zlfc'] = 6.1\n",
|
||||||
|
"gdf.at[9847, 'zlfc'] = 5.33\n",
|
||||||
|
"gdf_short = gdf[[\"GEOID10\", \"SF\", \"CF\", \"area\", \"zlfc\"]]\n",
|
||||||
|
"gdf_short_sorted = gdf_short.sort_values(by='area', ascending=False);\n",
|
||||||
|
"gdf_short_sorted.head(30)"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": null,
|
||||||
|
"id": "5930de0e",
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [],
|
||||||
|
"source": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metadata": {
|
||||||
|
"kernelspec": {
|
||||||
|
"display_name": "Python 3 (ipykernel)",
|
||||||
|
"language": "python",
|
||||||
|
"name": "python3"
|
||||||
|
},
|
||||||
|
"language_info": {
|
||||||
|
"codemirror_mode": {
|
||||||
|
"name": "ipython",
|
||||||
|
"version": 3
|
||||||
|
},
|
||||||
|
"file_extension": ".py",
|
||||||
|
"mimetype": "text/x-python",
|
||||||
|
"name": "python",
|
||||||
|
"nbconvert_exporter": "python",
|
||||||
|
"pygments_lexer": "ipython3",
|
||||||
|
"version": "3.9.13"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nbformat": 4,
|
||||||
|
"nbformat_minor": 5
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue