Skip to content

Commit a1abdcb

Browse files
committed
Add new guides as examples
1 parent 204718f commit a1abdcb

File tree

5 files changed

+2282
-2202
lines changed

5 files changed

+2282
-2202
lines changed

guide/12-enrich-data-with-thematic-information/part2_where_to_enrich_study_areas.ipynb

Lines changed: 1 addition & 222 deletions
Original file line numberDiff line numberDiff line change
@@ -3095,227 +3095,6 @@
30953095
"county_map.legend=True"
30963096
]
30973097
},
3098-
{
3099-
"cell_type": "markdown",
3100-
"metadata": {},
3101-
"source": [
3102-
"### Enriching Arbitrary Geometries"
3103-
]
3104-
},
3105-
{
3106-
"cell_type": "markdown",
3107-
"metadata": {},
3108-
"source": [
3109-
"Enrichment not only works on clearly defined geometries such as county or state boundaries but it can also power arbitrary goemetires (random polygon on a map or an area covering parts of different counties etc.) just as well. Let's look at an example of how an arbitrary geometry can be `enrich()`ed.\n",
3110-
"\n",
3111-
"In this example, we will:\n",
3112-
"1. Draw a map of Los Angeles, CA\n",
3113-
"2. Ask the user to draw a polygon on the map\n",
3114-
"3. Enrich the polygon drawn by the user\n",
3115-
"4. Visualize enriched geometry on a map"
3116-
]
3117-
},
3118-
{
3119-
"cell_type": "markdown",
3120-
"metadata": {},
3121-
"source": [
3122-
"#### Create a Map"
3123-
]
3124-
},
3125-
{
3126-
"cell_type": "code",
3127-
"execution_count": 48,
3128-
"metadata": {},
3129-
"outputs": [
3130-
{
3131-
"data": {
3132-
"application/vnd.jupyter.widget-view+json": {
3133-
"model_id": "4123363b1ef747d38056748b5e4d9d10",
3134-
"version_major": 2,
3135-
"version_minor": 0
3136-
},
3137-
"text/plain": [
3138-
"MapView(layout=Layout(height='400px', width='100%'))"
3139-
]
3140-
},
3141-
"metadata": {},
3142-
"output_type": "display_data"
3143-
},
3144-
{
3145-
"data": {
3146-
"text/html": [
3147-
"<div class=\"map-static-img-preview-0d046912-a010-4260-a277-c0330a5ff828\"><img src=\"\"></img></div>"
3148-
],
3149-
"text/plain": [
3150-
"<IPython.core.display.HTML object>"
3151-
]
3152-
},
3153-
"metadata": {},
3154-
"output_type": "display_data"
3155-
},
3156-
{
3157-
"data": {
3158-
"text/html": [
3159-
"<div class=\"map-html-embed-preview-0d046912-a010-4260-a277-c0330a5ff828\"></div>"
3160-
],
3161-
"text/plain": [
3162-
"<IPython.core.display.HTML object>"
3163-
]
3164-
},
3165-
"metadata": {},
3166-
"output_type": "display_data"
3167-
}
3168-
],
3169-
"source": [
3170-
"la_map = gis.map('Los Angeles, CA')\n",
3171-
"la_map"
3172-
]
3173-
},
3174-
{
3175-
"cell_type": "markdown",
3176-
"metadata": {},
3177-
"source": [
3178-
"#### Enable User Input\n",
3179-
"\n",
3180-
"Here, we will define a callback function that enables user input. If no input is provided, a default polygon geometry will be enriched."
3181-
]
3182-
},
3183-
{
3184-
"cell_type": "code",
3185-
"execution_count": 49,
3186-
"metadata": {},
3187-
"outputs": [],
3188-
"source": [
3189-
"# Define the callback function.\n",
3190-
"drawn_polygon = None\n",
3191-
"def draw_poly(la_map, g):\n",
3192-
" global drawn_polygon\n",
3193-
" drawn_polygon = g\n",
3194-
"\n",
3195-
"# Set draw_poly as the callback function to be invoked when a polygon is drawn on the map\n",
3196-
"drawn_polygon = la_map.on_draw_end(draw_poly)"
3197-
]
3198-
},
3199-
{
3200-
"cell_type": "markdown",
3201-
"metadata": {},
3202-
"source": [
3203-
"Now, run the cell below and then draw a polygon on `la_map`, finish drawing by double clicking the mouse pointer. If no map is drawn within 30 seconds, a default polygon geometry will be used for enrichment."
3204-
]
3205-
},
3206-
{
3207-
"cell_type": "code",
3208-
"execution_count": 50,
3209-
"metadata": {},
3210-
"outputs": [],
3211-
"source": [
3212-
"import time\n",
3213-
"# Draw polygon\n",
3214-
"la_map.draw(\"polygon\")\n",
3215-
"\n",
3216-
"# Sleep for 30 seconds\n",
3217-
"time.sleep(30)\n",
3218-
"\n",
3219-
"# Use this as default polygon if no polygon drawn on map\n",
3220-
"drawn_polygon = {'spatialReference': {'latestWkid': 3857, 'wkid': 102100},\n",
3221-
" 'rings': [[[-13176442.352731517, 4035051.715228523],\n",
3222-
" [-13167152.267973447, 4032788.462594141],\n",
3223-
" [-13169738.58648519, 4023675.1384639805],\n",
3224-
" [-13178995.82720767, 4028428.5661604665],\n",
3225-
" [-13176442.352731517, 4035051.715228523]]]}"
3226-
]
3227-
},
3228-
{
3229-
"cell_type": "code",
3230-
"execution_count": 51,
3231-
"metadata": {},
3232-
"outputs": [
3233-
{
3234-
"data": {
3235-
"text/plain": [
3236-
"{'spatialReference': {'latestWkid': 3857, 'wkid': 102100},\n",
3237-
" 'rings': [[[-13176442.352731517, 4035051.715228523],\n",
3238-
" [-13167152.267973447, 4032788.462594141],\n",
3239-
" [-13169738.58648519, 4023675.1384639805],\n",
3240-
" [-13178995.82720767, 4028428.5661604665],\n",
3241-
" [-13176442.352731517, 4035051.715228523]]]}"
3242-
]
3243-
},
3244-
"execution_count": 51,
3245-
"metadata": {},
3246-
"output_type": "execute_result"
3247-
}
3248-
],
3249-
"source": [
3250-
"# Check drawn polygon\n",
3251-
"drawn_polygon"
3252-
]
3253-
},
3254-
{
3255-
"cell_type": "markdown",
3256-
"metadata": {},
3257-
"source": [
3258-
"#### Enrich Drawn Geometry"
3259-
]
3260-
},
3261-
{
3262-
"cell_type": "code",
3263-
"execution_count": 52,
3264-
"metadata": {},
3265-
"outputs": [],
3266-
"source": [
3267-
"from arcgis.geometry import Polygon\n",
3268-
"poly = Polygon(drawn_polygon)"
3269-
]
3270-
},
3271-
{
3272-
"cell_type": "code",
3273-
"execution_count": null,
3274-
"metadata": {},
3275-
"outputs": [],
3276-
"source": [
3277-
"# Note: This will take some time to run\n",
3278-
"enriched_line_df2 = enrich(study_areas=[poly], \n",
3279-
" analysis_variables=[\"Age.FEM45\",\"Age.FEM55\",\"Age.FEM65\"])\n",
3280-
"\n",
3281-
"enriched_line_df2"
3282-
]
3283-
},
3284-
{
3285-
"cell_type": "markdown",
3286-
"metadata": {},
3287-
"source": [
3288-
"#### Visualize Enriched Geometry"
3289-
]
3290-
},
3291-
{
3292-
"cell_type": "code",
3293-
"execution_count": null,
3294-
"metadata": {},
3295-
"outputs": [],
3296-
"source": [
3297-
"# Plot on a map\n",
3298-
"poly_map2 = gis.map('Los Angeles, CA')\n",
3299-
"poly_map2"
3300-
]
3301-
},
3302-
{
3303-
"cell_type": "markdown",
3304-
"metadata": {},
3305-
"source": [
3306-
"We can clearly see the enriched geometry on this map. Clicking on the geometry will display enriched features."
3307-
]
3308-
},
3309-
{
3310-
"cell_type": "code",
3311-
"execution_count": null,
3312-
"metadata": {},
3313-
"outputs": [],
3314-
"source": [
3315-
"# Plot enriched area around line\n",
3316-
"enriched_line_df2.spatial.plot(poly_map2)"
3317-
]
3318-
},
33193098
{
33203099
"cell_type": "markdown",
33213100
"metadata": {},
@@ -3354,7 +3133,7 @@
33543133
"name": "python",
33553134
"nbconvert_exporter": "python",
33563135
"pygments_lexer": "ipython3",
3357-
"version": "3.9.11"
3136+
"version": "3.9.11 [MSC v.1931 64 bit (AMD64)]"
33583137
},
33593138
"livereveal": {
33603139
"scroll": true

guide/12-enrich-data-with-thematic-information/part3_where_to_enrich_named_stat_areas.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1384,7 +1384,7 @@
13841384
"name": "python",
13851385
"nbconvert_exporter": "python",
13861386
"pygments_lexer": "ipython3",
1387-
"version": "3.9.11"
1387+
"version": "3.9.11 [MSC v.1931 64 bit (AMD64)]"
13881388
},
13891389
"livereveal": {
13901390
"scroll": true

0 commit comments

Comments
 (0)