{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"id": "8f8408e6",
"metadata": {},
"outputs": [],
"source": [
"import geopandas as gpd"
]
},
{
"cell_type": "code",
"execution_count": 2,
"id": "d8461792",
"metadata": {},
"outputs": [],
"source": [
"import shapely"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "6bbb8081",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Bezeichnun | \n",
" Baumart | \n",
" Baumhöhe | \n",
" Kronenbrei | \n",
" Stammumfan | \n",
" Durchmesse | \n",
" Breitengra | \n",
" Längengra | \n",
" geometry | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" Tilia Cordata | \n",
" Linde | \n",
" 15.7 | \n",
" 5.3 | \n",
" 1.6 | \n",
" 0.0 | \n",
" 9.929020 | \n",
" 49.786065 | \n",
" POINT (4350885.205 5518545.260) | \n",
"
\n",
" \n",
" 1 | \n",
" Tilia Cordata | \n",
" Linde | \n",
" 13.3 | \n",
" 4.9 | \n",
" 1.0 | \n",
" 0.0 | \n",
" 9.934286 | \n",
" 49.794348 | \n",
" POINT (4351289.754 5519455.869) | \n",
"
\n",
" \n",
" 2 | \n",
" robinia pseudoacacia | \n",
" Robinie | \n",
" 17.7 | \n",
" 4.5 | \n",
" 1.7 | \n",
" 0.0 | \n",
" 9.942568 | \n",
" 49.795610 | \n",
" POINT (4351889.764 5519579.827) | \n",
"
\n",
" \n",
" 3 | \n",
" Tilia Cordata | \n",
" Linde | \n",
" 15.2 | \n",
" 5.0 | \n",
" 1.1 | \n",
" 0.0 | \n",
" 9.941988 | \n",
" 49.794548 | \n",
" POINT (4351844.785 5519462.881) | \n",
"
\n",
" \n",
" 4 | \n",
" robinia pseudoacacia | \n",
" Robinie | \n",
" 12.8 | \n",
" 4.2 | \n",
" 1.1 | \n",
" 0.0 | \n",
" 9.948865 | \n",
" 49.787736 | \n",
" POINT (4352319.118 5518691.817) | \n",
"
\n",
" \n",
" 5 | \n",
" Tilia Cordata | \n",
" Linde | \n",
" 13.8 | \n",
" 4.0 | \n",
" 1.3 | \n",
" 0.0 | \n",
" 9.950083 | \n",
" 49.787398 | \n",
" POINT (4352405.769 5518651.799) | \n",
"
\n",
" \n",
" 6 | \n",
" Tilia Cordata | \n",
" Linde | \n",
" 14.8 | \n",
" 3.4 | \n",
" 0.9 | \n",
" 0.0 | \n",
" 9.964250 | \n",
" 49.791921 | \n",
" POINT (4353439.338 5519127.002) | \n",
"
\n",
" \n",
" 7 | \n",
" robinia pseudoacacia | \n",
" Robinie | \n",
" 11.7 | \n",
" 4.3 | \n",
" 1.2 | \n",
" 0.0 | \n",
" 9.962506 | \n",
" 49.792440 | \n",
" POINT (4353315.381 5519188.121) | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Bezeichnun Baumart Baumhöhe Kronenbrei Stammumfan \\\n",
"0 Tilia Cordata Linde 15.7 5.3 1.6 \n",
"1 Tilia Cordata Linde 13.3 4.9 1.0 \n",
"2 robinia pseudoacacia Robinie 17.7 4.5 1.7 \n",
"3 Tilia Cordata Linde 15.2 5.0 1.1 \n",
"4 robinia pseudoacacia Robinie 12.8 4.2 1.1 \n",
"5 Tilia Cordata Linde 13.8 4.0 1.3 \n",
"6 Tilia Cordata Linde 14.8 3.4 0.9 \n",
"7 robinia pseudoacacia Robinie 11.7 4.3 1.2 \n",
"\n",
" Durchmesse Breitengra Längengra geometry \n",
"0 0.0 9.929020 49.786065 POINT (4350885.205 5518545.260) \n",
"1 0.0 9.934286 49.794348 POINT (4351289.754 5519455.869) \n",
"2 0.0 9.942568 49.795610 POINT (4351889.764 5519579.827) \n",
"3 0.0 9.941988 49.794548 POINT (4351844.785 5519462.881) \n",
"4 0.0 9.948865 49.787736 POINT (4352319.118 5518691.817) \n",
"5 0.0 9.950083 49.787398 POINT (4352405.769 5518651.799) \n",
"6 0.0 9.964250 49.791921 POINT (4353439.338 5519127.002) \n",
"7 0.0 9.962506 49.792440 POINT (4353315.381 5519188.121) "
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = gpd.read_file('Klimabäume_SImStadtUTm.shp')\n",
"df"
]
},
{
"cell_type": "code",
"execution_count": 4,
"id": "e0ceeefa",
"metadata": {},
"outputs": [],
"source": [
"df = df.to_crs(25832)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"id": "208df86b",
"metadata": {},
"outputs": [],
"source": [
"df = df.drop(columns=['Breitengra', 'Längengra'])"
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "d72ccb64",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"\n",
"Name: ETRS89 / UTM zone 32N\n",
"Axis Info [cartesian]:\n",
"- E[east]: Easting (metre)\n",
"- N[north]: Northing (metre)\n",
"Area of Use:\n",
"- name: Europe between 6°E and 12°E: Austria; Belgium; Denmark - onshore and offshore; Germany - onshore and offshore; Norway including - onshore and offshore; Spain - offshore.\n",
"- bounds: (6.0, 38.76, 12.01, 84.33)\n",
"Coordinate Operation:\n",
"- name: UTM zone 32N\n",
"- method: Transverse Mercator\n",
"Datum: European Terrestrial Reference System 1989 ensemble\n",
"- Ellipsoid: GRS 1980\n",
"- Prime Meridian: Greenwich"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df.crs"
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "8fbe258a",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Bezeichnun | \n",
" Baumart | \n",
" Baumhöhe | \n",
" Kronenbrei | \n",
" Stammumfan | \n",
" Durchmesse | \n",
" geometry | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" Tilia Cordata | \n",
" Linde | \n",
" 15.7 | \n",
" 5.3 | \n",
" 1.6 | \n",
" 0.0 | \n",
" POINT (566791.332 5515133.591) | \n",
"
\n",
" \n",
" 1 | \n",
" Tilia Cordata | \n",
" Linde | \n",
" 13.3 | \n",
" 4.9 | \n",
" 1.0 | \n",
" 0.0 | \n",
" POINT (567158.925 5516059.074) | \n",
"
\n",
" \n",
" 2 | \n",
" robinia pseudoacacia | \n",
" Robinie | \n",
" 17.7 | \n",
" 4.5 | \n",
" 1.7 | \n",
" 0.0 | \n",
" POINT (567753.134 5516206.830) | \n",
"
\n",
" \n",
" 3 | \n",
" Tilia Cordata | \n",
" Linde | \n",
" 15.2 | \n",
" 5.0 | \n",
" 1.1 | \n",
" 0.0 | \n",
" POINT (567712.891 5516088.252) | \n",
"
\n",
" \n",
" 4 | \n",
" robinia pseudoacacia | \n",
" Robinie | \n",
" 12.8 | \n",
" 4.2 | \n",
" 1.1 | \n",
" 0.0 | \n",
" POINT (568217.362 5515337.228) | \n",
"
\n",
" \n",
" 5 | \n",
" Tilia Cordata | \n",
" Linde | \n",
" 13.8 | \n",
" 4.0 | \n",
" 1.3 | \n",
" 0.0 | \n",
" POINT (568305.490 5515300.728) | \n",
"
\n",
" \n",
" 6 | \n",
" Tilia Cordata | \n",
" Linde | \n",
" 14.8 | \n",
" 3.4 | \n",
" 0.9 | \n",
" 0.0 | \n",
" POINT (569318.620 5515816.558) | \n",
"
\n",
" \n",
" 7 | \n",
" robinia pseudoacacia | \n",
" Robinie | \n",
" 11.7 | \n",
" 4.3 | \n",
" 1.2 | \n",
" 0.0 | \n",
" POINT (569192.394 5515872.638) | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Bezeichnun Baumart Baumhöhe Kronenbrei Stammumfan \\\n",
"0 Tilia Cordata Linde 15.7 5.3 1.6 \n",
"1 Tilia Cordata Linde 13.3 4.9 1.0 \n",
"2 robinia pseudoacacia Robinie 17.7 4.5 1.7 \n",
"3 Tilia Cordata Linde 15.2 5.0 1.1 \n",
"4 robinia pseudoacacia Robinie 12.8 4.2 1.1 \n",
"5 Tilia Cordata Linde 13.8 4.0 1.3 \n",
"6 Tilia Cordata Linde 14.8 3.4 0.9 \n",
"7 robinia pseudoacacia Robinie 11.7 4.3 1.2 \n",
"\n",
" Durchmesse geometry \n",
"0 0.0 POINT (566791.332 5515133.591) \n",
"1 0.0 POINT (567158.925 5516059.074) \n",
"2 0.0 POINT (567753.134 5516206.830) \n",
"3 0.0 POINT (567712.891 5516088.252) \n",
"4 0.0 POINT (568217.362 5515337.228) \n",
"5 0.0 POINT (568305.490 5515300.728) \n",
"6 0.0 POINT (569318.620 5515816.558) \n",
"7 0.0 POINT (569192.394 5515872.638) "
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df"
]
},
{
"cell_type": "code",
"execution_count": 8,
"id": "38000721",
"metadata": {},
"outputs": [],
"source": [
"df.to_file(\"Klimabäume_SImStadt.shp\", encoding='utf-8')"
]
},
{
"cell_type": "code",
"execution_count": 9,
"id": "40cad6d4",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"\n",
"\n",
"
\n",
" \n",
" \n",
" | \n",
" Bezeichnun | \n",
" Baumart | \n",
" Baumhöhe | \n",
" Kronenbrei | \n",
" Stammumfan | \n",
" Durchmesse | \n",
" geometry | \n",
"
\n",
" \n",
" \n",
" \n",
" 0 | \n",
" Tilia Cordata | \n",
" Linde | \n",
" 15.7 | \n",
" 5.3 | \n",
" 1.6 | \n",
" 0.0 | \n",
" POINT (566791.332 5515133.591) | \n",
"
\n",
" \n",
" 1 | \n",
" Tilia Cordata | \n",
" Linde | \n",
" 13.3 | \n",
" 4.9 | \n",
" 1.0 | \n",
" 0.0 | \n",
" POINT (567158.925 5516059.074) | \n",
"
\n",
" \n",
" 2 | \n",
" robinia pseudoacacia | \n",
" Robinie | \n",
" 17.7 | \n",
" 4.5 | \n",
" 1.7 | \n",
" 0.0 | \n",
" POINT (567753.134 5516206.830) | \n",
"
\n",
" \n",
" 3 | \n",
" Tilia Cordata | \n",
" Linde | \n",
" 15.2 | \n",
" 5.0 | \n",
" 1.1 | \n",
" 0.0 | \n",
" POINT (567712.891 5516088.252) | \n",
"
\n",
" \n",
" 4 | \n",
" robinia pseudoacacia | \n",
" Robinie | \n",
" 12.8 | \n",
" 4.2 | \n",
" 1.1 | \n",
" 0.0 | \n",
" POINT (568217.362 5515337.228) | \n",
"
\n",
" \n",
" 5 | \n",
" Tilia Cordata | \n",
" Linde | \n",
" 13.8 | \n",
" 4.0 | \n",
" 1.3 | \n",
" 0.0 | \n",
" POINT (568305.490 5515300.728) | \n",
"
\n",
" \n",
" 6 | \n",
" Tilia Cordata | \n",
" Linde | \n",
" 14.8 | \n",
" 3.4 | \n",
" 0.9 | \n",
" 0.0 | \n",
" POINT (569318.620 5515816.558) | \n",
"
\n",
" \n",
" 7 | \n",
" robinia pseudoacacia | \n",
" Robinie | \n",
" 11.7 | \n",
" 4.3 | \n",
" 1.2 | \n",
" 0.0 | \n",
" POINT (569192.394 5515872.638) | \n",
"
\n",
" \n",
"
\n",
"
"
],
"text/plain": [
" Bezeichnun Baumart Baumhöhe Kronenbrei Stammumfan \\\n",
"0 Tilia Cordata Linde 15.7 5.3 1.6 \n",
"1 Tilia Cordata Linde 13.3 4.9 1.0 \n",
"2 robinia pseudoacacia Robinie 17.7 4.5 1.7 \n",
"3 Tilia Cordata Linde 15.2 5.0 1.1 \n",
"4 robinia pseudoacacia Robinie 12.8 4.2 1.1 \n",
"5 Tilia Cordata Linde 13.8 4.0 1.3 \n",
"6 Tilia Cordata Linde 14.8 3.4 0.9 \n",
"7 robinia pseudoacacia Robinie 11.7 4.3 1.2 \n",
"\n",
" Durchmesse geometry \n",
"0 0.0 POINT (566791.332 5515133.591) \n",
"1 0.0 POINT (567158.925 5516059.074) \n",
"2 0.0 POINT (567753.134 5516206.830) \n",
"3 0.0 POINT (567712.891 5516088.252) \n",
"4 0.0 POINT (568217.362 5515337.228) \n",
"5 0.0 POINT (568305.490 5515300.728) \n",
"6 0.0 POINT (569318.620 5515816.558) \n",
"7 0.0 POINT (569192.394 5515872.638) "
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df = gpd.read_file('Klimabäume_SImStadt.shp')\n",
"df"
]
},
{
"cell_type": "code",
"execution_count": 10,
"id": "b5df1e3f",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['Bezeichnun',\n",
" 'Baumart',\n",
" 'Baumhöhe',\n",
" 'Kronenbrei',\n",
" 'Stammumfan',\n",
" 'Durchmesse',\n",
" 'geometry']"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"list(df)"
]
},
{
"cell_type": "code",
"execution_count": 11,
"id": "c26ecc76",
"metadata": {},
"outputs": [],
"source": [
"poly = df.geometry[0]"
]
},
{
"cell_type": "code",
"execution_count": 12,
"id": "43d36ff6",
"metadata": {},
"outputs": [
{
"data": {
"image/svg+xml": [
""
],
"text/plain": [
""
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"poly"
]
},
{
"cell_type": "code",
"execution_count": 13,
"id": "67377424",
"metadata": {},
"outputs": [],
"source": [
"poly2d = shapely.ops.transform(lambda *args: args[:2], poly)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"id": "9bab724b",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'POINT (566791.3315698793 5515133.590795662)'"
]
},
"execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"poly2d.wkt"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "29537f36",
"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.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 5
}