Skip to content

Commit

Permalink
Add support for editing vector data interactively (#879)
Browse files Browse the repository at this point in the history
* Add support for editing vector data interactively

* Fix style column issue

* Fix geojson color style issue

* Add support for editing lines and polygons
  • Loading branch information
giswqs authored Sep 1, 2024
1 parent 1d7fe2c commit 4f11760
Show file tree
Hide file tree
Showing 3 changed files with 323 additions and 28 deletions.
76 changes: 74 additions & 2 deletions docs/notebooks/95_edit_vector.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@
"id": "5",
"metadata": {},
"source": [
"## Save edits\n",
"\n",
"Save the edits to a new file. Choose any of the supported formats by GeoPandas, such as GeoJSON, Shapefile, or GeoPackage."
]
},
Expand All @@ -75,6 +73,80 @@
"source": [
"m.save_edits(\"cities.geojson\")"
]
},
{
"cell_type": "markdown",
"id": "7",
"metadata": {},
"source": [
"## Edit lines"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "8",
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"# Load any vector dataset that can be loaded by GeoPandas\n",
"geojson_url = (\n",
" \"https://github.com/opengeos/datasets/releases/download/places/nyc_roads.geojson\"\n",
")\n",
"m.edit_polygons(geojson_url)\n",
"m"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "9",
"metadata": {},
"outputs": [],
"source": [
"m.save_edits(\"nyc_roads.geojson\")"
]
},
{
"cell_type": "markdown",
"id": "10",
"metadata": {},
"source": [
"## Edit polygons"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "11",
"metadata": {},
"outputs": [],
"source": [
"m = leafmap.Map()\n",
"# Load any vector dataset that can be loaded by GeoPandas\n",
"geojson_url = \"https://github.com/opengeos/datasets/releases/download/places/nyc_buildings.geojson\"\n",
"m.edit_polygons(geojson_url)\n",
"m"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "12",
"metadata": {},
"outputs": [],
"source": [
"m.save_edits(\"nyc_buildings.geojson\")"
]
},
{
"cell_type": "markdown",
"id": "13",
"metadata": {},
"source": [
"![image](https://github.com/user-attachments/assets/4ef42f54-d6a6-4a77-9651-743d5fe9fef9)"
]
}
],
"metadata": {
Expand Down
Loading

0 comments on commit 4f11760

Please sign in to comment.