fio-l2-capetown-landuse-dissolve
Map (reference ← swipe → agent)
0:00
I'm prepping a transit-corridor study for the Cape Town metro, and I need a class-level summary of `landuse` so the team's spatial-SQL notebooks can join it against the bus-route table. Can you give me one row per landuse class with the geometry unified into a single MultiPolygon, the total area in m², and the count of source parcels that fed in? Please write the result to `landuse_dissolved.geoparquet` with `class`, `area_m2`, and `parcel_count` columns.
0:00
System info
{
"adapter": "openrouter",
"model": "deepseek/deepseek-v4-flash",
"base_url": "https://openrouter.ai/api/v1"
}
0:01
The user wants to process a landuse dataset for the Cape Town metro area. They want me to: 1. Read a landuse file (presumably in the working directory) 2. Dissolve (union) geometries by landuse class into a single MultiPolygon per class 3. Calculate total area in m² for each class 4. Count the number of source parcels (features) per class 5. Write the result to `landuse_dissolved.geoparquet` with columns: `class`, `area_m2`, `parcel_count` Let me first check what files are available in the working directory.
0:01
Bash
ls -la /work/
total 15884 drwxr-xr-x 1 agent agent 40 Jun 8 10:40 . drwxr-xr-x 1 root root 14 Jun 8 10:40 .. -rw-r--r-- 1 agent agent 16264656 Jun 8 10:40 capetown_landuse.fgb
0:04
Let's first inspect the input file to understand its structure - what columns it has, what CRS, and what the landuse classes look like.
0:04
Bash
cd /work && python -c "
cd /work && python -c "
import geopandas as gpd
gdf = gpd.read_file('capetown_landuse.fgb')
print('Shape:', gdf.shape)
print('Columns:', gdf.columns.tolist())
print('CRS:', gdf.crs)
print('Classes:', sorted(gdf['landuse'].unique()) if 'landuse' in gdf.columns else 'no landuse column')
print('Geometry types:', gdf.geometry.type.unique())
print(gdf.head(3).to_string())
"
Shape: (30978, 4)
Columns: ['id', 'class', 'subtype', 'geometry']
CRS: EPSG:32734
Classes: no landuse column
Geometry types: <ArrowStringArray>
['MultiPolygon']
Length: 1, dtype: str
id class subtype
[... truncated ...] MULTIPOLYGON (((255047.308 6280773.284, 255024.832 6280770.235, 255024.382 6280766.017, 255023.558 6280762.966, 255022.786 6280755.366, 255022.714 6280752.745, 255050.97 6280757.539, 255047.308 6280773.284)))
0:11
The data has columns: `id`, `class`, `subtype`, `geometry`. So the landuse class is in the `class` column. All geometries are MultiPolygon. CRS is EPSG:32734 (UTM zone 34S, which is metric - correct for Cape Town area). I need to: 1. Read the FlatGeobuf file 2. Dissolve by the `class` column, unioning geometries 3. Calculate area in m² (since CRS is already metric, can use `area` attribute directly) 4. Count the number of source parcels per class 5. Write to `landuse_dissolved.geoparquet` with `class`, `area_m2`, and `parcel_count` columns Let me write the script.
0:11
Write
/work/solve.py
content · 30 lines · py
import geopandas as gpd
import pandas as pd
# 1. Read the source FlatGeobuf
gdf = gpd.read_file("/work/capetown_landuse.fgb")
print(f"Read {len(gdf)} parcels, CRS: {gdf.crs}")
# 2. Verify we have the expected columns
print(f"Columns: {gdf.columns.tolist()}")
print(f"Classes: {sorted(gdf['class'].unique())}")
# 3. Dissolve by class — union geometries, count parcels
dissolved = gdf.dissolve(by="class", aggfunc="count")
# After dissolve, the index is the class value, and 'id' holds the count
# (any column would do since count is the same for all)
dissolved = dissolved.reset_index()
dissolved = dissolved.rename(columns={"class": "class", "id": "parcel_count"})
# 4. Compute area in m² (CRS is EPSG:32734 – UTM 34S, metric)
dissolved["area_m2"] = dissolved.geometry.area
# 5. Select only the three output columns
result = dissolved[["class", "area_m2", "parcel_count"]].copy()
print(f"\nResult: {len(result)} rows")
print(result.head(10).to_string())
# 6. Write GeoParquet
result.to_parquet("/work/landuse_dissolved.geoparquet", index=False)
print("\nWritten → landuse_dissolved.geoparquet")
Wrote /work/solve.py (1101 chars).
0:13
Let me run this script.
0:13
Bash
cd /work && python solve.py
Read 30978 parcels, CRS: EPSG:32734
Columns: ['id', 'class', 'subtype', 'geometry']
Classes: ['airfield', 'allotments', 'animal_keeping', 'barracks', 'base', 'beach_resort', 'brownfield', 'bunker', 'camp_site', 'cemetery', 'clinic', 'college', 'commercial', 'construction', 'doctors', 'dog_park', 'driving_range', 'education', 'fairway', 'farmland', 'farmyard', 'flowerbed', 'garages', 'garden', 'golf_course', 'grass', 'grave_yard', 'green', 'greenfield', 'greenhouse_horticulture', 'hospital', 'industrial', 'kindergarten', 'landfill', 'lateral_water_hazard', 'marina', 'meadow', 'military', 'music_school', 'national_park', 'nature_reserve', 'naval_base', 'orchard', 'park', 'pedestrian', 'pitch', 'plant_nursery', 'playground', 'plaza', 'protected_landscape_seascape', 'quarry', 'railway', 'recreation_ground', 'religious', 'residential', 'resort', 'retail', 'rough', 'school', 'species_management_area', 'stadium', 'tee', 'track', 'training_area', 'university', 'village_green', 'vineyard', 'water_hazard', 'water_park', 'wilderness_area', 'works', 'zoo']
Result: 72 rows
class area_m2 parcel_count
0 airfield 2.444056e+06 1
1 allotments 1.715652e+04 215
2 animal_keeping 6.636804e+05 302
3 barracks 1.873189e+03 4
4 base 9.244053e+05 1
5 beach_resort 2.936896e+05 1
6 brownfield 1.418610e+05 13
7 bunker 6.712463e+04 638
8 camp_site 8.568784e+05 13
9 cemetery 4.515795e+06 65
Written → landuse_dissolved.geoparquet
0:20
The script ran successfully. Let me verify the output file exists and do a quick sanity check.
0:20
Bash
cd /work && python -c "
cd /work && python -c "
import geopandas as gpd
gdf = gpd.read_parquet('landuse_dissolved.geoparquet')
print('Rows:', len(gdf))
print('Columns:', gdf.columns.tolist())
print('Dtypes:')
print(gdf.dtypes)
print()
print(gdf.head(10).to_string())
print()
print('Geometry type:', gdf.geometry.type.unique())
print('CRS:', gdf.crs)
print()
# Sanity: area_m2 magnitudes — UTM 34S should be ~1e3–1e8 for parcels
print('Area range:', gdf['area_m2'].min(), '–', gdf['area_m2'].max())
print('Count range:', gdf['parcel_count'].min(), '–', gdf['parcel_count'].max())
print('All geometries are MultiPolygon?', (gdf.geometry.type == 'MultiPolygon').all())
"
Traceback (most recent call last):
File "<string>", line 3, in <module>
gdf = gpd.read_parquet('landuse_dissolved.geoparquet')
File "/usr/local/lib/python3.14/site-packages/geopandas/io/arrow.py", line 774, in _read_parquet
geo_metadata = _validate_and_decode_metadata(metadata)
File "/usr/local/lib/python3.14/site-packages/geopandas/io/arrow.py", line 623, in _validate_and_decode_metadata
raise ValueError(
...<2 lines>...
)
ValueError: Missing geo metadata in Parquet/Feather file.
Use pandas.read_parquet/read_feather() instead.
0:23
The issue is that `to_parquet` doesn't include the geo metadata by default when called on a GeoDataFrame. Need to use `to_parquet` with appropriate engine or write with geo metadata. Let me check what's happening. Actually, `geopandas.GeoDataFrame.to_parquet()` should write geo metadata by default when using pyarrow engine. Let me check the version or fix the approach. Let me use the `geoarrow` based approach or ensure we're using the right engine/config.
0:23
Read
/work/solve.py
1 import geopandas as gpd
2 import pandas as pd
3
4 # 1. Read the source FlatGeobuf
5 gdf = gpd.read_file("/work/capetown_landuse.fgb")
6 print(f"Read {len(gdf)} parcels, CRS: {gdf.crs}")
7
8 # 2. Verify we have the expected columns
9 print(f"Columns: {gdf.columns.tolist()}")
10 print(f"Classes: {sorted(gdf['class'].unique())}")
11
12 # 3. Dissolve by class — union geometries, count parcels
13 dissolved = gdf.dissolve(by="class", aggfunc="count")
14 # After dissolve, the index is the class value, and 'id' holds the count
15 # (any column would do since count is the same for all)
16 dissolved = dissolved.reset_index()
17 dissolved = dissolved.rename(columns={"class": "class", "id": "parcel_count"})
18
19 # 4. Compute area in m² (CRS is EPSG:32734 – UTM 34S, metric)
20 dissolved["area_m2"] = dissolved.geometry.area
21
22 # 5. Select only the three output columns
23 result = dissolved[["class", "area_m2", "parcel_count"]].copy()
24
25 print(f"\nResult: {len(result)} rows")
26 print(result.head(10).to_string())
27
28 # 6. Write GeoParquet
29 result.to_parquet("/work/landuse_dissolved.geoparquet", index=False)
30 print("\nWritten → landuse_dissolved.geoparquet")
0:29
The issue is that `to_parquet()` from geopandas doesn't properly write geo metadata when we use a sliced/selected GeoDataFrame like this. Let me use `gpd.GeoDataFrame` explicitly and ensure geometry is preserved. Actually, looking at the error more carefully, the issue might be that `result` is a plain DataFrame (not GeoDataFrame) because of the column selection. Let me check: `dissolved[["class", "area_m2", "parcel_count"]]` — but `dissolved` IS a GeoDataFrame since it came from dissolve, so selecting columns should keep it as GeoDataFrame... Actually, let me check — when you do `.copy()` on a GeoDataFrame, it should remain a GeoDataFrame. But the error is about reading, not writing.
Wait, the error is on read: `gpd.read_parquet('landuse_dissolved.geoparquet')` — it says "Missing geo metadata in Parquet/Feather file."
Let me check if the file was actually written as a proper GeoParquet. Let me use `pyarrow.parquet` or `duckdb` to check.
Actually, maybe the issue is that when writing with `to_parquet` from a GeoDataFrame, geopandas is supposed to write the geo metadata. Let me check if this is a known issue. Actually, let me just try writing using the `geopandas.GeoDataFrame.to_parquet` method, but ensure the geometry column isn't dropped.
Wait, the `.copy()` on a GeoDataFrame might strip the GeoDataFrame type. Let me try a different approach - explicitly keep it as GeoDataFrame.
0:29
Edit
/work/solve.py
Edited /work/solve.py.
0:31
Let me re-run to verify the fix.
0:31
Bash
cd /work && python solve.py
Read 30978 parcels, CRS: EPSG:32734
Columns: ['id', 'class', 'subtype', 'geometry']
Classes: ['airfield', 'allotments', 'animal_keeping', 'barracks', 'base', 'beach_resort', 'brownfield', 'bunker', 'camp_site', 'cemetery', 'clinic', 'college', 'commercial', 'construction', 'doctors', 'dog_park', 'driving_range', 'education', 'fairway', 'farmland', 'farmyard', 'flowerbed', 'garages', 'garden', 'golf_course', 'grass', 'grave_yard', 'green', 'greenfield', 'greenhouse_horticulture', 'hospital', 'industrial', 'kindergarten', 'landfill', 'lateral_water_hazard', 'marina', 'meadow', 'military', 'music_school', 'national_park', 'nature_reserve', 'naval_base', 'orchard', 'park', 'pedestrian', 'pitch', 'plant_nursery', 'playground', 'plaza', 'protected_landscape_seascape', 'quarry', 'railway', 'recreation_ground', 'religious', 'residential', 'resort', 'retail', 'rough', 'school', 'species_management_area', 'stadium', 'tee', 'track', 'training_area', 'university', 'village_green', 'vineyard', 'water_hazard', 'water_park', 'wilderness_area', 'works', 'zoo']
Result: 72 rows
class area_m2 parcel_count
[... truncated ...]170.525, 270632.197 6244220.329, 270634.939 6244217.121, 270640.71 6244191.569, 270671.51 6244198.117, 270664.355 6244227.343, 271471.275 6244410.445, 271896.843 6244506.263, 272072.57 6244546.61, 272260.118 6244589.834, 272263.408 6244586.917, 272270.844 6244588.583, 272272.773 6244592.247, 272522.728 6244649.893, 272546.806 6244643.245, 272557.924 6244631.038, 272575.642 6244549.637, 272601.757 6244567.987, 272608.573 6244547.652, 272579.751 6244528.372, 272614.168 6244409.939, 272645.938 6244337.088, 272560.265 6244295.249, 272447.715 6244253.03, 272346.13 6244217.388, 272163.91 6244166.413, 272032.075 6244140.628, 271345.73 6244011.52, 270938.426 6243942.419, 270489.284 6243862.377, 270277.317 6243823.108, 270274.708 6243837.616, 270216.042 6243827.65, 270218.487 6243811.883, 270178.72 6243805.459, 269537.126 6243691.585, 269527.722 6243685.64, 269457.628 6243675.802, 269387.231 6243678.763, 269352.354 6243693.852, 269235.963 6243742.561, 269171.127 6243770.605, 269238.017 6243893.147, 269556.219 6243971.623, 269881.705 6244047.456, 270151.203 6244109.448, 270194.017 6244119.252, 270199.385 6244118.017, 270204.041 6244115.289)), ((260783.979 6244560.709, 260769.648 6244573.833, 260781.237 6244585.791, 260795.239 6244572.159, 260783.979 6244560.709)), ((257274.324 6255387.942, 257242.352 6255431.934, 257277.533 6255458.348, 257310.36 6255413.889, 257274.324 6255387.942)), ((302420.262 6219266.984, 302441.02 6219287.537, 302425.056 6219303.146, 302444.006 6219325.481, 302401.792 6219364.539, 302400.559 6219365.678, 302419.394 6219385.569, 302521.363 6219288.791, 302520.07 6219280.065, 302520.706 6219277.937, 302507.318 6219269.234, 302462.257 6219229.552, 302420.262 6219266.984)), ((300405.74 6222213.144, 300616.722 6221880.785, 300611.193 6221864.291, 300553.317 6221822.853, 300542.766 6221823.905, 300323.015 6222160.67, 300405.74 6222213.144)), ((300002.399 6224961.101, 299895.391 6225050.382, 300067.451 6225136.366, 300084.469 6225128.271, 300146.394 6225074.183, 300128.886 6225055.304, 300119.197 6225063.842, 300045.041 6224984.364, 300002.399 6224961.101)), ((300895.865 6226119.554, 300757.009 6226026.433, 300620.444 6226216.658, 300899.344 6226297.982, 300905.197 6226296.685, 300910.247 6226294.939, 300988.548 6226189.806, 300986.514 6226180.331, 300895.865 6226119.554)), ((285152.361 6235227.042, 285136.008 6235221.111, 285141.044 6235206.921, 285120.755 6235204.973, 285025.537 6235222.673, 285006.584 6235233.106, 285082.253 6235285.04, 285103.342 6235278.606, 285119.254 6235254.787, 285173.893 6235245.042, 285167.026 6235236.131, 285152.361 6235227.042)), ((287931.066 6236608.34, 287932.246 6236605.159, 287933.776 6236596.704, 287933.566 6236593.715, 287922.522 6236502.496, 287922.06 6236500.033, 287915.51 6236465.209, 287919.069 6236447.878, 287914.941 6236440.695, 287775.929 6236351.867, 287717.338 6236540.928, 287852.568 6236686.399, 287887.431 6236711.715, 287889.736 6236703.311, 287893.763 6236692.316, 287931.066 6236608.34)), ((281136.383 6236925.051, 281162.648 6236890.579, 281189.38 6236855.509, 281167.872 6236839.398, 281176.242 6236828.427, 281179.599 6236734.4, 281105.15 6236731.879, 281104.22 6236732.113, 281099.205 6236731.93, 280891.576 6236724.616, 280871.292 6236724.313, 280879.572 6236769.138, 280954.632 6236815.587, 281031.213 6236854.624, 281047.806 6236863.464, 281080.998 6236883.597, 281124.339 6236915.017, 281136.383 6236925.051)), ((289653.373 6237139.707, 289655.205 6237140.036, 289656.913 6237139.73, 289658.509 6237139.011, 289659.421 6237138.332, 289660.269 6237137.175, 289660.693 6237135.597, 289660.528 6237134.284, 289663.313 6237133.325, 289662.933 6237132.129, 289672.224 6237128.763, 289804.98 6236844.178, 289801.177 6236832.287, 289803.816 6236826.676, 289811.082 6236811.268, 289813.866 6236805.36, 289827.052 6236800.538, 289846.131 6236759.316, 289813.318 6236743.862, 289735.884 6236707.409, 289473.097 6236947.156, 289408.308 6237012.416, 289410.023 6237014.684, 289411.492 6237016.781, 289412.109 6237019.391, 289411.797 6237021.759, 289637.429 6237140.473, 289647.608 6237137.071, 289648.025 6237138.278, 289650.661 6237137.372, 289651.657 6237138.736, 289653.373 6237139.707)), ((289882.697 6237263.068, 289909.438 6237215.225, 289992.202 6237259.995, 290194.175 6236892.031, 289945.393 6236768.955, 289745.61 6237187.829, 289882.697 6237263.068)), ((271883.394 6237094.358, 271884.15 6237088.694, 271889.242 6237083.024, 271893.125 6237081.508, 271888.199 6237033.878, 271808.768 6237062.816, 271852.14 6237192.333, 271888.346 6237171.609, 271902.389 6237170.472, 271902.826 6237126.667, 271898.723 6237126.934, 271887.532 6237128.274, 271883.394 6237094.358)), ((276778.115 6236863.862, 276763.217 6236871.901, 276752.835 6236851.536, 275919.067 6237225.554, 276053.197 6237487.229, 276895.857 6237109.989, 276881.039 6237068.755, 276788.361 6236861.374, 276774.362 6236855.994, 276778.115 6236863.862)), ((290126.386 6237137.803, 290023.687 6237327.45, 290298.4 6237474.123, 290445.38 6237227.308, 290252.899 6237123.453, 290251.038 6237126.907, 290218.975 6237186.384, 290126.386 6237137.803)), ((278584.514 6241140.988, 278600.273 6241100.262, 278620.87 6241068.561, 278658.006 6241079.505, 278685.482 6241046.699, 278756.673 6240999.743, 278742.87 6240971.034, 278675.531 6240830.899, 278158.481 6241010.35, 278175.951 6241096.909, 278338.669 6241210.071, 278538.336 6241311.164, 278577.268 6241289.624, 278591.492 6241198.991, 278612.315 6241151.714, 278584.514 6241140.988)), ((286180.507 6241964.969, 286041.536 6242210.8, 286202.872 6242301.184, 286342.167 6242054.747, 286335.691 6242051.117, 286338.6 6242045.978, 286239.96 6241990.712, 286236.714 6241996.453, 286180.507 6241964.969)), ((300369.05 6242618.351, 300380.808 6242621.65, 300451.482 6242640.547, 300523.69 6242662.56, 300578.347 6242682.351, 300593.289 6242661.805, 300600.633 6242630.97, 300625.555 6242619.644, 300678.077 6242634.451, 300701.636 6242640.872, 300703.42 6242631.655, 300704.821 6242624.417, 300707.476 6242610.748, 300717.421 6242562.647, 300719.902 6242550.638, 300629.934 6242517.39, 300662.539 6242394.382, 300662.493 6242313.883, 300718.539 6242314.573, 300742.611 6242231.385, 300692.976 6242209.105, 300610.432 6242289.088, 300582.263 6242283.813, 300539.625 6242329.817, 300470.15 6242377.986, 300425.773 6242435.814, 300383.816 6242520.111, 300355.165 6242614.564, 300369.05 6242618.351)), ((300099.277 6242721.271, 300147.732 6242675.879, 300215.931 6242612.13, 300310.106 6242533.871, 300280.198 6242469.785, 300160.754 6242540.721, 300078.715 6242590.719, 299994.248 6242643.506, 299953.51 6242681.658, 299923.413 6242726.948, 300022.662 6242795.949, 300028.703 6242786.201, 300032.961 6242785.115, 300043.915 6242782.328, 300062.603 6242754.816, 300079.879 6242739.014, 300099.277 6242721.271)), ((283919.921 6245577.146, 283940.992 6245600.608, 283984.864 6245650.333, 284003.853 6245634.752, 284022.915 6245656.625, 284004.343 6245672.171, 284091.347 6245770.904, 284115.8 6245798.648, 284263.98 6245668.389, 284132.235 6245287.2, 284099.836 6245270.839, 283871.388 6245473.339, 283871.221 6245474.168, 283871.424 6245474.993, 283871.925 6245476.57, 283866.128 6245481.675, 283864.819 6245480.647, 283863.824 6245480.424, 283863.048 6245480.806, 283847.359 6245494.486, 283919.921 6245577.146)), ((291668.524 6251540.037, 291666.993 6251543.543, 291674.171 6251560.722, 291676.43 6251561.159, 291686.394 6251585.09, 291685.554 6251587.091, 291695.624 6251610.858, 291697.706 6251611.769, 291707.91 6251635.317, 291707.079 6251637.34, 291717.349 6251661.311, 291719.396 6251662.066, 291720.35 6251664.617, 291722.997 6251663.776, 291726.21 6251666.298, 291729.241 6251664.856, 291730.205 6251666.896, 291740.902 6251662.492, 291739.673 6251659.414, 291747.42 6251656.532, 291748.4 6251659.128, 291755.568 6251656.034, 291761.183 6251669.361, 291763.161 6251669.948, 291773.424 6251693.763, 291772.61 6251695.854, 291782.732 6251719.788, 291784.83 6251720.388, 291795.013 6251744.091, 291794.035 6251746.044, 291804.266 6251770.081, 291806.288 6251770.769, 291816.649 6251794.785, 291815.76 6251796.941, 291826.023 6251820.778, 291827.978 6251821.586, 291838.242 6251845.368, 291837.412 6251847.369, 291846.853 6251871.111, 291849.648 6251872.027, 291859.651 6251895.081, 291858.862 6251897.294, 291868.936 6251920.883, 291871.077 6251921.629, 291881.066 6251945.36, 291880.301 6251947.718, 291890.615 6251971.379, 291892.798 6251972.303, 291902.882 6251995.937, 291902.011 6251998.059, 291912.345 6252021.665, 291906.476 6252187.934, 292112.989 6252195.079, 291483.633 6251076.914, 291436.366 6251099.723, 291439.58 6251106.806, 291452.664 6251100.702, 291467.176 6251136.295, 291619.1 6251490.508, 291636.082 6251483.168, 291643.867 6251501.77, 291656.94 6251532.97, 291664.322 6251529.814, 291668.524 6251540.037)), ((287329.752 6252608.105, 287217.367 6252386.214, 287210.601 6252372.469, 287169.215 6252285.945, 287159.609 6252279.527, 287071.72 6252324.055, 287065.927 6252401.689, 287029.692 6252399.447, 287001.92 6252780.545, 287158.668 6252701.062, 287165.927 6252693.191, 287169.315 6252691.591, 287177.393 6252691.405, 287327.603 6252615.169, 287329.752 6252608.105)), ((298870.802 6256180.465, 298856.464 6256188.883, 298865.227 6256203.67, 298879.566 6256195.251, 298870.802 6256180.465)), ((286805.006 6258565.516, 286905.189 6258712.52, 287186.455 6258464.23, 287074.933 6258348.268, 286999.844 6258405.068, 287000.285 6258405.633, 286998.916 6258410.496, 286996.609 6258412.186, 286993.133 6258414.728, 286988.843 6258414.332, 286988.312 6258413.643, 286807.105 6258551.615, 286805.006 6258565.516)), ((276015.29 6272411.027, 275970.936 6272344.35, 275949.261 6272359.812, 275911.316 6272386.867, 275956.16 6272452.035, 276015.29 6272411.027)), ((303272.046 6221021.959, 302940.739 6220781.883, 302811.547 6220961.192, 303143.314 6221197.565, 303145.459 6221199.097, 303272.046 6221021.959)), ((307781.056 6222066.906, 307855.293 6222172.141, 307947.406 6222105.862, 307892.383 6222025.363, 307837.057 6221946.211, 307811.515 6221909.663, 307702.711 6221982.645, 307781.056 6222066.906)), ((304114.966 6223923.305, 304176.036 6224003.276, 304370.088 6223857.949, 304301.996 6223802.322, 304114.966 6223923.305)), ((311123.398 6244595.456, 311086.271 6244566.758, 311065.825 6244585.578, 311046.82 6244569.256, 311017.765 6244594.018, 311030.111 6244614.545, 311011.805 6244633.696, 311004.505 6244642.16, 311081.954 6244667.889, 311123.398 6244595.456)), ((310958.952 6244895.655, 311012.514 6244790.789, 310953.139 6244738.981, 310880.693 6244845.079, 310958.952 6244895.655)), ((310325.773 6245766.994, 310329.95 6245769.053, 310359.285 6245778.648, 310384.27 6245723.584, 310352.109 6245712.812, 310373.853 6245673.616, 310339.729 6245674.099, 310319.235 6245740.503, 310319.966 6245750.702, 310321.716 6245756.174, 310326.764 6245760.901, 310325.773 6245766.994)), ((311154.141 6247343.606, 311115.214 6247304.3, 311126.013 6247410.236, 311136.337 6247440.076, 311162.858 6247478.891, 311167.13 6247475.747, 311181.182 6247480.476, 311216.62 6247470.063, 311229.81 6247456.757, 311195.429 6247388.396, 311154.141 6247343.606)), ((311470.481 6253781.547, 311376.622 6253747.069, 311351.918 6253784.145, 311438.511 6253830.251, 311470.481 6253781.547)), ((303580.594 6257251.298, 303625.997 6257138.942, 303584.015 6257151.402, 303561.78 6257158, 303458.899 6257203.321, 303580.594 6257251.298)), ((311431.217 6264167.735, 311397.648 6264149.01, 311370.785 6264137.474, 311259.077 6264097.158, 311250.113 6264198.55, 311448.707 6264270.026, 311475.376 6264279.218, 311547.217 6264304.389, 311551.94 6264236.007, 311461.286 6264180.71, 311431.217 6264167.735)), ((311765.508 6264535.872, 311711.789 6264536.788, 311714.51 6264594.366, 311776.307 6264587.052, 311765.508 6264535.872)), ((311719.971 6264696.286, 311821.069 6264694.074, 311800.5 6264651.854, 311785.456 6264609.111, 311779.56 6264605.411, 311714.899 6264605.634, 311719.971 6264696.286)), ((313133.725 6264875.73, 313141.165 6264763.591, 313119.327 6264595.984, 313114.063 6264540.998, 313117.018 6264507.43, 313132.804 6264470.883, 313144.084 6264448.594, 313147.934 6264384.899, 313159.438 6264375.794, 313163.041 6264364.049, 313149.643 6264351.561, 313043.665 6264333.434, 312792.823 6264288.537, 312545.596 6264282.445, 312518.117 6264383.429, 312516.605 6264528.89, 312544.714 6264529.475, 312541.783 6264584.345, 312513.596 6264582.56, 312512.057 6264645.878, 312547.015 6264644.09, 312547.146 6264627.496, 312597.443 6264627.64, 312592.111 6264577.234, 312619.762 6264574.725, 312630.346 6264697.114, 312649.432 6264913.904, 312576.694 6264922.229, 312533.571 6264927.696, 312520.804 6264944.885, 312526.837 6265036.565, 312530.757 6265046.039, 312540.572 6265058.857, 312561.514 6265074.733, 312571.505 6265079.012, 312590.412 6265078.151, 312666.612 6265071.969, 312736.116 6265096.219, 312750.138 6265097.736, 313008.925 6265073.106, 313022.622 6265071.765, 313074.63 6265062.765, 313151.234 6265048.676, 313213.257 6265042.212, 313206.06 6264971.801, 313212.146 6264870.585, 313133.725 6264875.73)), ((310838.087 6265269.483, 310773.822 6265275.633, 310771.037 6265340.913, 310842.76 6265334.911, 310838.087 6265269.483)), ((314533.695 6268847.952, 314288.876 6268762.991, 314249.733 6268870.665, 314258.095 6268888.4, 314262.789 6268889.723, 314238.584 6268996.444, 314244.905 6269003.744, 314373.489 6269068.134, 314426.125 6269059.748, 314456.411 6269075.434, 314533.695 6268847.952)), ((305937.56 6272404.538, 306035.675 6272415.634, 306048.041 6272295.619, 305986.429 6272277.185, 305958.372 6272268.285, 305947.885 6272307.902, 305929.656 6272394.481, 305937.56 6272404.538)), ((314098.126 6273995.797, 313910.298 6274032.012, 313941.793 6274187.862, 313955.985 6274189.957, 314083.609 6274170.201, 314173.966 6274139.937, 314178.44 6274063.242, 314098.126 6273995.797)), ((314396.114 6274668.366, 314388.343 6274680.618, 314369.397 6274836.798, 314567.845 6274753.941, 314674.644 6274584.594, 314750.665 6274372.561, 314633.766 6274292.021, 314471.517 6274549.456, 314396.114 6274668.366)), ((314091.904 6275313.365, 314104.581 6275314.165, 314111.638 6275287.122, 314100.43 6275284.73, 314108.85 6275245.266, 314127.118 6275249.647, 314137.773 6275206.875, 314104.958 6275195.711, 314089.34 6275195.341, 314075.351 6275191.853, 313997.707 6275159.383, 313985.237 6275186.632, 313894.448 6275145.486, 313857.301 6275232.208, 313910.417 6275255.838, 313927.145 6275285.084, 313998.037 6275318.855, 314016.442 6275326.212, 314031.264 6275286.794, 314091.904 6275313.365)), ((314304.624 6280495.838, 314280.887 6280478.949, 314191.227 6280570.537, 314231.495 6280615.891, 314247.712 6280616.482, 314304.624 6280495.838)), ((313858.383 6280675.163, 313821.091 6280723.508, 313832.551 6280735.756, 313860.031 6280763.547, 313889.968 6280767.111, 313921.333 6280735.247, 313893.032 6280692.309, 313865.805 6280658.2, 313858.383 6280675.163)))
Written → landuse_dissolved.geoparquet
0:39
The script ran successfully. Let me verify the output file is valid by reading it properly with the right method.
0:39
Bash
cd /work && python -c "
cd /work && python -c "
import geopandas as gpd
gdf = gpd.read_parquet('landuse_dissolved.geoparquet')
print('Rows:', len(gdf))
print('Columns:', gdf.columns.tolist())
print('Dtypes:')
print(gdf.dtypes)
print()
print(gdf.head(10).to_string())
print()
print('Geometry type:', gdf.geometry.type.unique())
print('CRS:', gdf.crs)
print()
# Sanity: area_m2 magnitudes — UTM 34S should be ~1e3–1e8 for parcels
print('Area range:', gdf['area_m2'].min(), '–', gdf['area_m2'].max())
print('Count range:', gdf['parcel_count'].min(), '–', gdf['parcel_count'].max())
print('All geometries are MultiPolygon?', (gdf.geometry.type == 'MultiPolygon').all())
"
Rows: 72
Columns: ['class', 'area_m2', 'parcel_count', 'geometry']
Dtypes:
class str
area_m2 float64
parcel_count int64
geometry geometry
dtype: object
class area_m2 parcel_count
[... truncated ...].026 6235236.131, 285152.361 6235227.042)), ((287931.066 6236608.34, 287932.246 6236605.159, 287933.776 6236596.704, 287933.566 6236593.715, 287922.522 6236502.496, 287922.06 6236500.033, 287915.51 6236465.209, 287919.069 6236447.878, 287914.941 6236440.695, 287775.929 6236351.867, 287717.338 6236540.928, 287852.568 6236686.399, 287887.431 6236711.715, 287889.736 6236703.311, 287893.763 6236692.316, 287931.066 6236608.34)), ((281136.383 6236925.051, 281162.648 6236890.579, 281189.38 6236855.509, 281167.872 6236839.398, 281176.242 6236828.427, 281179.599 6236734.4, 281105.15 6236731.879, 281104.22 6236732.113, 281099.205 6236731.93, 280891.576 6236724.616, 280871.292 6236724.313, 280879.572 6236769.138, 280954.632 6236815.587, 281031.213 6236854.624, 281047.806 6236863.464, 281080.998 6236883.597, 281124.339 6236915.017, 281136.383 6236925.051)), ((289653.373 6237139.707, 289655.205 6237140.036, 289656.913 6237139.73, 289658.509 6237139.011, 289659.421 6237138.332, 289660.269 6237137.175, 289660.693 6237135.597, 289660.528 6237134.284, 289663.313 6237133.325, 289662.933 6237132.129, 289672.224 6237128.763, 289804.98 6236844.178, 289801.177 6236832.287, 289803.816 6236826.676, 289811.082 6236811.268, 289813.866 6236805.36, 289827.052 6236800.538, 289846.131 6236759.316, 289813.318 6236743.862, 289735.884 6236707.409, 289473.097 6236947.156, 289408.308 6237012.416, 289410.023 6237014.684, 289411.492 6237016.781, 289412.109 6237019.391, 289411.797 6237021.759, 289637.429 6237140.473, 289647.608 6237137.071, 289648.025 6237138.278, 289650.661 6237137.372, 289651.657 6237138.736, 289653.373 6237139.707)), ((289882.697 6237263.068, 289909.438 6237215.225, 289992.202 6237259.995, 290194.175 6236892.031, 289945.393 6236768.955, 289745.61 6237187.829, 289882.697 6237263.068)), ((271883.394 6237094.358, 271884.15 6237088.694, 271889.242 6237083.024, 271893.125 6237081.508, 271888.199 6237033.878, 271808.768 6237062.816, 271852.14 6237192.333, 271888.346 6237171.609, 271902.389 6237170.472, 271902.826 6237126.667, 271898.723 6237126.934, 271887.532 6237128.274, 271883.394 6237094.358)), ((276778.115 6236863.862, 276763.217 6236871.901, 276752.835 6236851.536, 275919.067 6237225.554, 276053.197 6237487.229, 276895.857 6237109.989, 276881.039 6237068.755, 276788.361 6236861.374, 276774.362 6236855.994, 276778.115 6236863.862)), ((290126.386 6237137.803, 290023.687 6237327.45, 290298.4 6237474.123, 290445.38 6237227.308, 290252.899 6237123.453, 290251.038 6237126.907, 290218.975 6237186.384, 290126.386 6237137.803)), ((278584.514 6241140.988, 278600.273 6241100.262, 278620.87 6241068.561, 278658.006 6241079.505, 278685.482 6241046.699, 278756.673 6240999.743, 278742.87 6240971.034, 278675.531 6240830.899, 278158.481 6241010.35, 278175.951 6241096.909, 278338.669 6241210.071, 278538.336 6241311.164, 278577.268 6241289.624, 278591.492 6241198.991, 278612.315 6241151.714, 278584.514 6241140.988)), ((286180.507 6241964.969, 286041.536 6242210.8, 286202.872 6242301.184, 286342.167 6242054.747, 286335.691 6242051.117, 286338.6 6242045.978, 286239.96 6241990.712, 286236.714 6241996.453, 286180.507 6241964.969)), ((300369.05 6242618.351, 300380.808 6242621.65, 300451.482 6242640.547, 300523.69 6242662.56, 300578.347 6242682.351, 300593.289 6242661.805, 300600.633 6242630.97, 300625.555 6242619.644, 300678.077 6242634.451, 300701.636 6242640.872, 300703.42 6242631.655, 300704.821 6242624.417, 300707.476 6242610.748, 300717.421 6242562.647, 300719.902 6242550.638, 300629.934 6242517.39, 300662.539 6242394.382, 300662.493 6242313.883, 300718.539 6242314.573, 300742.611 6242231.385, 300692.976 6242209.105, 300610.432 6242289.088, 300582.263 6242283.813, 300539.625 6242329.817, 300470.15 6242377.986, 300425.773 6242435.814, 300383.816 6242520.111, 300355.165 6242614.564, 300369.05 6242618.351)), ((300099.277 6242721.271, 300147.732 6242675.879, 300215.931 6242612.13, 300310.106 6242533.871, 300280.198 6242469.785, 300160.754 6242540.721, 300078.715 6242590.719, 299994.248 6242643.506, 299953.51 6242681.658, 299923.413 6242726.948, 300022.662 6242795.949, 300028.703 6242786.201, 300032.961 6242785.115, 300043.915 6242782.328, 300062.603 6242754.816, 300079.879 6242739.014, 300099.277 6242721.271)), ((283919.921 6245577.146, 283940.992 6245600.608, 283984.864 6245650.333, 284003.853 6245634.752, 284022.915 6245656.625, 284004.343 6245672.171, 284091.347 6245770.904, 284115.8 6245798.648, 284263.98 6245668.389, 284132.235 6245287.2, 284099.836 6245270.839, 283871.388 6245473.339, 283871.221 6245474.168, 283871.424 6245474.993, 283871.925 6245476.57, 283866.128 6245481.675, 283864.819 6245480.647, 283863.824 6245480.424, 283863.048 6245480.806, 283847.359 6245494.486, 283919.921 6245577.146)), ((291668.524 6251540.037, 291666.993 6251543.543, 291674.171 6251560.722, 291676.43 6251561.159, 291686.394 6251585.09, 291685.554 6251587.091, 291695.624 6251610.858, 291697.706 6251611.769, 291707.91 6251635.317, 291707.079 6251637.34, 291717.349 6251661.311, 291719.396 6251662.066, 291720.35 6251664.617, 291722.997 6251663.776, 291726.21 6251666.298, 291729.241 6251664.856, 291730.205 6251666.896, 291740.902 6251662.492, 291739.673 6251659.414, 291747.42 6251656.532, 291748.4 6251659.128, 291755.568 6251656.034, 291761.183 6251669.361, 291763.161 6251669.948, 291773.424 6251693.763, 291772.61 6251695.854, 291782.732 6251719.788, 291784.83 6251720.388, 291795.013 6251744.091, 291794.035 6251746.044, 291804.266 6251770.081, 291806.288 6251770.769, 291816.649 6251794.785, 291815.76 6251796.941, 291826.023 6251820.778, 291827.978 6251821.586, 291838.242 6251845.368, 291837.412 6251847.369, 291846.853 6251871.111, 291849.648 6251872.027, 291859.651 6251895.081, 291858.862 6251897.294, 291868.936 6251920.883, 291871.077 6251921.629, 291881.066 6251945.36, 291880.301 6251947.718, 291890.615 6251971.379, 291892.798 6251972.303, 291902.882 6251995.937, 291902.011 6251998.059, 291912.345 6252021.665, 291906.476 6252187.934, 292112.989 6252195.079, 291483.633 6251076.914, 291436.366 6251099.723, 291439.58 6251106.806, 291452.664 6251100.702, 291467.176 6251136.295, 291619.1 6251490.508, 291636.082 6251483.168, 291643.867 6251501.77, 291656.94 6251532.97, 291664.322 6251529.814, 291668.524 6251540.037)), ((287329.752 6252608.105, 287217.367 6252386.214, 287210.601 6252372.469, 287169.215 6252285.945, 287159.609 6252279.527, 287071.72 6252324.055, 287065.927 6252401.689, 287029.692 6252399.447, 287001.92 6252780.545, 287158.668 6252701.062, 287165.927 6252693.191, 287169.315 6252691.591, 287177.393 6252691.405, 287327.603 6252615.169, 287329.752 6252608.105)), ((298870.802 6256180.465, 298856.464 6256188.883, 298865.227 6256203.67, 298879.566 6256195.251, 298870.802 6256180.465)), ((286805.006 6258565.516, 286905.189 6258712.52, 287186.455 6258464.23, 287074.933 6258348.268, 286999.844 6258405.068, 287000.285 6258405.633, 286998.916 6258410.496, 286996.609 6258412.186, 286993.133 6258414.728, 286988.843 6258414.332, 286988.312 6258413.643, 286807.105 6258551.615, 286805.006 6258565.516)), ((276015.29 6272411.027, 275970.936 6272344.35, 275949.261 6272359.812, 275911.316 6272386.867, 275956.16 6272452.035, 276015.29 6272411.027)), ((303272.046 6221021.959, 302940.739 6220781.883, 302811.547 6220961.192, 303143.314 6221197.565, 303145.459 6221199.097, 303272.046 6221021.959)), ((307781.056 6222066.906, 307855.293 6222172.141, 307947.406 6222105.862, 307892.383 6222025.363, 307837.057 6221946.211, 307811.515 6221909.663, 307702.711 6221982.645, 307781.056 6222066.906)), ((304114.966 6223923.305, 304176.036 6224003.276, 304370.088 6223857.949, 304301.996 6223802.322, 304114.966 6223923.305)), ((311123.398 6244595.456, 311086.271 6244566.758, 311065.825 6244585.578, 311046.82 6244569.256, 311017.765 6244594.018, 311030.111 6244614.545, 311011.805 6244633.696, 311004.505 6244642.16, 311081.954 6244667.889, 311123.398 6244595.456)), ((310958.952 6244895.655, 311012.514 6244790.789, 310953.139 6244738.981, 310880.693 6244845.079, 310958.952 6244895.655)), ((310325.773 6245766.994, 310329.95 6245769.053, 310359.285 6245778.648, 310384.27 6245723.584, 310352.109 6245712.812, 310373.853 6245673.616, 310339.729 6245674.099, 310319.235 6245740.503, 310319.966 6245750.702, 310321.716 6245756.174, 310326.764 6245760.901, 310325.773 6245766.994)), ((311154.141 6247343.606, 311115.214 6247304.3, 311126.013 6247410.236, 311136.337 6247440.076, 311162.858 6247478.891, 311167.13 6247475.747, 311181.182 6247480.476, 311216.62 6247470.063, 311229.81 6247456.757, 311195.429 6247388.396, 311154.141 6247343.606)), ((311470.481 6253781.547, 311376.622 6253747.069, 311351.918 6253784.145, 311438.511 6253830.251, 311470.481 6253781.547)), ((303580.594 6257251.298, 303625.997 6257138.942, 303584.015 6257151.402, 303561.78 6257158, 303458.899 6257203.321, 303580.594 6257251.298)), ((311431.217 6264167.735, 311397.648 6264149.01, 311370.785 6264137.474, 311259.077 6264097.158, 311250.113 6264198.55, 311448.707 6264270.026, 311475.376 6264279.218, 311547.217 6264304.389, 311551.94 6264236.007, 311461.286 6264180.71, 311431.217 6264167.735)), ((311765.508 6264535.872, 311711.789 6264536.788, 311714.51 6264594.366, 311776.307 6264587.052, 311765.508 6264535.872)), ((311719.971 6264696.286, 311821.069 6264694.074, 311800.5 6264651.854, 311785.456 6264609.111, 311779.56 6264605.411, 311714.899 6264605.634, 311719.971 6264696.286)), ((313133.725 6264875.73, 313141.165 6264763.591, 313119.327 6264595.984, 313114.063 6264540.998, 313117.018 6264507.43, 313132.804 6264470.883, 313144.084 6264448.594, 313147.934 6264384.899, 313159.438 6264375.794, 313163.041 6264364.049, 313149.643 6264351.561, 313043.665 6264333.434, 312792.823 6264288.537, 312545.596 6264282.445, 312518.117 6264383.429, 312516.605 6264528.89, 312544.714 6264529.475, 312541.783 6264584.345, 312513.596 6264582.56, 312512.057 6264645.878, 312547.015 6264644.09, 312547.146 6264627.496, 312597.443 6264627.64, 312592.111 6264577.234, 312619.762 6264574.725, 312630.346 6264697.114, 312649.432 6264913.904, 312576.694 6264922.229, 312533.571 6264927.696, 312520.804 6264944.885, 312526.837 6265036.565, 312530.757 6265046.039, 312540.572 6265058.857, 312561.514 6265074.733, 312571.505 6265079.012, 312590.412 6265078.151, 312666.612 6265071.969, 312736.116 6265096.219, 312750.138 6265097.736, 313008.925 6265073.106, 313022.622 6265071.765, 313074.63 6265062.765, 313151.234 6265048.676, 313213.257 6265042.212, 313206.06 6264971.801, 313212.146 6264870.585, 313133.725 6264875.73)), ((310838.087 6265269.483, 310773.822 6265275.633, 310771.037 6265340.913, 310842.76 6265334.911, 310838.087 6265269.483)), ((314533.695 6268847.952, 314288.876 6268762.991, 314249.733 6268870.665, 314258.095 6268888.4, 314262.789 6268889.723, 314238.584 6268996.444, 314244.905 6269003.744, 314373.489 6269068.134, 314426.125 6269059.748, 314456.411 6269075.434, 314533.695 6268847.952)), ((305937.56 6272404.538, 306035.675 6272415.634, 306048.041 6272295.619, 305986.429 6272277.185, 305958.372 6272268.285, 305947.885 6272307.902, 305929.656 6272394.481, 305937.56 6272404.538)), ((314098.126 6273995.797, 313910.298 6274032.012, 313941.793 6274187.862, 313955.985 6274189.957, 314083.609 6274170.201, 314173.966 6274139.937, 314178.44 6274063.242, 314098.126 6273995.797)), ((314396.114 6274668.366, 314388.343 6274680.618, 314369.397 6274836.798, 314567.845 6274753.941, 314674.644 6274584.594, 314750.665 6274372.561, 314633.766 6274292.021, 314471.517 6274549.456, 314396.114 6274668.366)), ((314091.904 6275313.365, 314104.581 6275314.165, 314111.638 6275287.122, 314100.43 6275284.73, 314108.85 6275245.266, 314127.118 6275249.647, 314137.773 6275206.875, 314104.958 6275195.711, 314089.34 6275195.341, 314075.351 6275191.853, 313997.707 6275159.383, 313985.237 6275186.632, 313894.448 6275145.486, 313857.301 6275232.208, 313910.417 6275255.838, 313927.145 6275285.084, 313998.037 6275318.855, 314016.442 6275326.212, 314031.264 6275286.794, 314091.904 6275313.365)), ((314304.624 6280495.838, 314280.887 6280478.949, 314191.227 6280570.537, 314231.495 6280615.891, 314247.712 6280616.482, 314304.624 6280495.838)), ((313858.383 6280675.163, 313821.091 6280723.508, 313832.551 6280735.756, 313860.031 6280763.547, 313889.968 6280767.111, 313921.333 6280735.247, 313893.032 6280692.309, 313865.805 6280658.2, 313858.383 6280675.163)))
Geometry type: <ArrowStringArray>
['Polygon', 'MultiPolygon']
Length: 2, dtype: str
CRS: {"$schema": "https://proj.org/schemas/v0.7/projjson.schema.json", "type": "ProjectedCRS", "name": "WGS 84 / UTM zone 34S", "base_crs": {"name": "WGS 84", "datum_ensemble": {"name": "World Geodetic System 1984 ensemble", "members": [{"name": "World Geodetic System 1984 (Transit)"}, {"name": "World Geodetic System 1984 (G730)"}, {"name": "World Geodetic System 1984 (G873)"}, {"name": "World Geodetic System 1984 (G1150)"}, {"name": "World Geodetic System 1984 (G1674)"}, {"name": "World Geodetic System 1984 (G1762)"}, {"name": "World Geodetic System 1984 (G2139)"}, {"name": "World Geodetic System 1984 (G2296)"}], "ellipsoid": {"name": "WGS 84", "semi_major_axis": 6378137, "inverse_flattening": 298.257223563}, "accuracy": "2.0", "id": {"authority": "EPSG", "code": 6326}}, "coordinate_system": {"subtype": "ellipsoidal", "axis": [{"name": "Geodetic latitude", "abbreviation": "Lat", "direction": "north", "unit": "degree"}, {"name": "Geodetic longitude", "abbreviation": "Lon", "direction": "east", "unit": "degree"}]}, "id": {"authority": "EPSG", "code": 4326}}, "conversion": {"name": "UTM zone 34S", "method": {"name": "Transverse Mercator", "id": {"authority": "EPSG", "code": 9807}}, "parameters": [{"name": "Latitude of natural origin", "value": 0, "unit": "degree", "id": {"authority": "EPSG", "code": 8801}}, {"name": "Longitude of natural origin", "value": 21, "unit": "degree", "id": {"authority": "EPSG", "code": 8802}}, {"name": "Scale factor at natural origin", "value": 0.9996, "unit": "unity", "id": {"authority": "EPSG", "code": 8805}}, {"name": "False easting", "value": 500000, "unit": "metre", "id": {"authority": "EPSG", "code": 8806}}, {"name": "False northing", "value": 10000000, "unit": "metre", "id": {"authority": "EPSG", "code": 8807}}]}, "coordinate_system": {"subtype": "Cartesian", "axis": [{"name": "Easting", "abbreviation": "E", "direction": "east", "unit": "metre"}, {"name": "Northing", "abbreviation": "N", "direction": "north", "unit": "metre"}]}, "scope": "Navigation and medium accuracy spatial referencing.", "area": "Between 18\u00b0E and 24\u00b0E, southern hemisphere between 80\u00b0S and equator, onshore and offshore. Angola. Botswana. Democratic Republic of the Congo (Zaire). Namibia. South Africa. Zambia.", "bbox": {"south_latitude": -80, "west_longitude": 18, "north_latitude": 0, "east_longitude": 24}, "id": {"authority": "EPSG", "code": 32734}}
Area range: 140.77184518329355 – 1700275799.2303958
Count range: 1 – 8476
All geometries are MultiPolygon? False
0:42
The output shows that not all geometries are MultiPolygon — some came out as Polygon from the dissolve operation (when only one polygon exists in a class). The user asked for "the geometry unified into a single MultiPolygon". So I should ensure every geometry is a MultiPolygon. Let me fix this.
0:42
0:42
Read
/work/solve.py
1 import geopandas as gpd
2 import pandas as pd
3
4 # 1. Read the source FlatGeobuf
5 gdf = gpd.read_file("/work/capetown_landuse.fgb")
6 print(f"Read {len(gdf)} parcels, CRS: {gdf.crs}")
7
8 # 2. Verify we have the expected columns
9 print(f"Columns: {gdf.columns.tolist()}")
10 print(f"Classes: {sorted(gdf['class'].unique())}")
11
12 # 3. Dissolve by class — union geometries, count parcels
13 dissolved = gdf.dissolve(by="class", aggfunc="count")
14 # After dissolve, the index is the class value, and 'id' holds the count
15 # (any column would do since count is the same for all)
16 dissolved = dissolved.reset_index()
17 dissolved = dissolved.rename(columns={"class": "class", "id": "parcel_count"})
18
19 # 4. Compute area in m² (CRS is EPSG:32734 – UTM 34S, metric)
20 dissolved["area_m2"] = dissolved.geometry.area
21
22 # 5. Select only the three output columns (keep geometry via loc)
23 result = gpd.GeoDataFrame(
24 dissolved[["class", "area_m2", "parcel_count", "geometry"]].copy(),
25 geometry="geometry",
26 crs=dissolved.crs,
27 )
28
29 print(f"\nResult: {len(result)} rows")
30 print(result.head(10).to_string())
31
32 # 6. Write GeoParquet
33 result.to_parquet("/work/landuse_dissolved.geoparquet", index=False)
34 print("\nWritten → landuse_dissolved.geoparquet")
0:44
I need to add a step to convert any Polygon to MultiPolygon. The user said "the geometry unified into a single MultiPolygon". Let me add that.
0:44
Edit
/work/solve.py
Edited /work/solve.py.
0:46
Now I need to add a step after dissolve (or before writing) to convert any Polygon to MultiPolygon.
0:46
Edit
/work/solve.py
Edited /work/solve.py.
0:49
Also need to renumber the Write comment step number.
0:49
Edit
/work/solve.py
Edited /work/solve.py.
0:51
Let me run the updated script and verify.
0:51
Bash
cd /work && python solve.py
Read 30978 parcels, CRS: EPSG:32734
Columns: ['id', 'class', 'subtype', 'geometry']
Classes: ['airfield', 'allotments', 'animal_keeping', 'barracks', 'base', 'beach_resort', 'brownfield', 'bunker', 'camp_site', 'cemetery', 'clinic', 'college', 'commercial', 'construction', 'doctors', 'dog_park', 'driving_range', 'education', 'fairway', 'farmland', 'farmyard', 'flowerbed', 'garages', 'garden', 'golf_course', 'grass', 'grave_yard', 'green', 'greenfield', 'greenhouse_horticulture', 'hospital', 'industrial', 'kindergarten', 'landfill', 'lateral_water_hazard', 'marina', 'meadow', 'military', 'music_school', 'national_park', 'nature_reserve', 'naval_base', 'orchard', 'park', 'pedestrian', 'pitch', 'plant_nursery', 'playground', 'plaza', 'protected_landscape_seascape', 'quarry', 'railway', 'recreation_ground', 'religious', 'residential', 'resort', 'retail', 'rough', 'school', 'species_management_area', 'stadium', 'tee', 'track', 'training_area', 'university', 'village_green', 'vineyard', 'water_hazard', 'water_park', 'wilderness_area', 'works', 'zoo']
Result: 72 rows
class area_m2 parcel_count
[... truncated ...]170.525, 270632.197 6244220.329, 270634.939 6244217.121, 270640.71 6244191.569, 270671.51 6244198.117, 270664.355 6244227.343, 271471.275 6244410.445, 271896.843 6244506.263, 272072.57 6244546.61, 272260.118 6244589.834, 272263.408 6244586.917, 272270.844 6244588.583, 272272.773 6244592.247, 272522.728 6244649.893, 272546.806 6244643.245, 272557.924 6244631.038, 272575.642 6244549.637, 272601.757 6244567.987, 272608.573 6244547.652, 272579.751 6244528.372, 272614.168 6244409.939, 272645.938 6244337.088, 272560.265 6244295.249, 272447.715 6244253.03, 272346.13 6244217.388, 272163.91 6244166.413, 272032.075 6244140.628, 271345.73 6244011.52, 270938.426 6243942.419, 270489.284 6243862.377, 270277.317 6243823.108, 270274.708 6243837.616, 270216.042 6243827.65, 270218.487 6243811.883, 270178.72 6243805.459, 269537.126 6243691.585, 269527.722 6243685.64, 269457.628 6243675.802, 269387.231 6243678.763, 269352.354 6243693.852, 269235.963 6243742.561, 269171.127 6243770.605, 269238.017 6243893.147, 269556.219 6243971.623, 269881.705 6244047.456, 270151.203 6244109.448, 270194.017 6244119.252, 270199.385 6244118.017, 270204.041 6244115.289)), ((260783.979 6244560.709, 260769.648 6244573.833, 260781.237 6244585.791, 260795.239 6244572.159, 260783.979 6244560.709)), ((257274.324 6255387.942, 257242.352 6255431.934, 257277.533 6255458.348, 257310.36 6255413.889, 257274.324 6255387.942)), ((302420.262 6219266.984, 302441.02 6219287.537, 302425.056 6219303.146, 302444.006 6219325.481, 302401.792 6219364.539, 302400.559 6219365.678, 302419.394 6219385.569, 302521.363 6219288.791, 302520.07 6219280.065, 302520.706 6219277.937, 302507.318 6219269.234, 302462.257 6219229.552, 302420.262 6219266.984)), ((300405.74 6222213.144, 300616.722 6221880.785, 300611.193 6221864.291, 300553.317 6221822.853, 300542.766 6221823.905, 300323.015 6222160.67, 300405.74 6222213.144)), ((300002.399 6224961.101, 299895.391 6225050.382, 300067.451 6225136.366, 300084.469 6225128.271, 300146.394 6225074.183, 300128.886 6225055.304, 300119.197 6225063.842, 300045.041 6224984.364, 300002.399 6224961.101)), ((300895.865 6226119.554, 300757.009 6226026.433, 300620.444 6226216.658, 300899.344 6226297.982, 300905.197 6226296.685, 300910.247 6226294.939, 300988.548 6226189.806, 300986.514 6226180.331, 300895.865 6226119.554)), ((285152.361 6235227.042, 285136.008 6235221.111, 285141.044 6235206.921, 285120.755 6235204.973, 285025.537 6235222.673, 285006.584 6235233.106, 285082.253 6235285.04, 285103.342 6235278.606, 285119.254 6235254.787, 285173.893 6235245.042, 285167.026 6235236.131, 285152.361 6235227.042)), ((287931.066 6236608.34, 287932.246 6236605.159, 287933.776 6236596.704, 287933.566 6236593.715, 287922.522 6236502.496, 287922.06 6236500.033, 287915.51 6236465.209, 287919.069 6236447.878, 287914.941 6236440.695, 287775.929 6236351.867, 287717.338 6236540.928, 287852.568 6236686.399, 287887.431 6236711.715, 287889.736 6236703.311, 287893.763 6236692.316, 287931.066 6236608.34)), ((281136.383 6236925.051, 281162.648 6236890.579, 281189.38 6236855.509, 281167.872 6236839.398, 281176.242 6236828.427, 281179.599 6236734.4, 281105.15 6236731.879, 281104.22 6236732.113, 281099.205 6236731.93, 280891.576 6236724.616, 280871.292 6236724.313, 280879.572 6236769.138, 280954.632 6236815.587, 281031.213 6236854.624, 281047.806 6236863.464, 281080.998 6236883.597, 281124.339 6236915.017, 281136.383 6236925.051)), ((289653.373 6237139.707, 289655.205 6237140.036, 289656.913 6237139.73, 289658.509 6237139.011, 289659.421 6237138.332, 289660.269 6237137.175, 289660.693 6237135.597, 289660.528 6237134.284, 289663.313 6237133.325, 289662.933 6237132.129, 289672.224 6237128.763, 289804.98 6236844.178, 289801.177 6236832.287, 289803.816 6236826.676, 289811.082 6236811.268, 289813.866 6236805.36, 289827.052 6236800.538, 289846.131 6236759.316, 289813.318 6236743.862, 289735.884 6236707.409, 289473.097 6236947.156, 289408.308 6237012.416, 289410.023 6237014.684, 289411.492 6237016.781, 289412.109 6237019.391, 289411.797 6237021.759, 289637.429 6237140.473, 289647.608 6237137.071, 289648.025 6237138.278, 289650.661 6237137.372, 289651.657 6237138.736, 289653.373 6237139.707)), ((289882.697 6237263.068, 289909.438 6237215.225, 289992.202 6237259.995, 290194.175 6236892.031, 289945.393 6236768.955, 289745.61 6237187.829, 289882.697 6237263.068)), ((271883.394 6237094.358, 271884.15 6237088.694, 271889.242 6237083.024, 271893.125 6237081.508, 271888.199 6237033.878, 271808.768 6237062.816, 271852.14 6237192.333, 271888.346 6237171.609, 271902.389 6237170.472, 271902.826 6237126.667, 271898.723 6237126.934, 271887.532 6237128.274, 271883.394 6237094.358)), ((276778.115 6236863.862, 276763.217 6236871.901, 276752.835 6236851.536, 275919.067 6237225.554, 276053.197 6237487.229, 276895.857 6237109.989, 276881.039 6237068.755, 276788.361 6236861.374, 276774.362 6236855.994, 276778.115 6236863.862)), ((290126.386 6237137.803, 290023.687 6237327.45, 290298.4 6237474.123, 290445.38 6237227.308, 290252.899 6237123.453, 290251.038 6237126.907, 290218.975 6237186.384, 290126.386 6237137.803)), ((278584.514 6241140.988, 278600.273 6241100.262, 278620.87 6241068.561, 278658.006 6241079.505, 278685.482 6241046.699, 278756.673 6240999.743, 278742.87 6240971.034, 278675.531 6240830.899, 278158.481 6241010.35, 278175.951 6241096.909, 278338.669 6241210.071, 278538.336 6241311.164, 278577.268 6241289.624, 278591.492 6241198.991, 278612.315 6241151.714, 278584.514 6241140.988)), ((286180.507 6241964.969, 286041.536 6242210.8, 286202.872 6242301.184, 286342.167 6242054.747, 286335.691 6242051.117, 286338.6 6242045.978, 286239.96 6241990.712, 286236.714 6241996.453, 286180.507 6241964.969)), ((300369.05 6242618.351, 300380.808 6242621.65, 300451.482 6242640.547, 300523.69 6242662.56, 300578.347 6242682.351, 300593.289 6242661.805, 300600.633 6242630.97, 300625.555 6242619.644, 300678.077 6242634.451, 300701.636 6242640.872, 300703.42 6242631.655, 300704.821 6242624.417, 300707.476 6242610.748, 300717.421 6242562.647, 300719.902 6242550.638, 300629.934 6242517.39, 300662.539 6242394.382, 300662.493 6242313.883, 300718.539 6242314.573, 300742.611 6242231.385, 300692.976 6242209.105, 300610.432 6242289.088, 300582.263 6242283.813, 300539.625 6242329.817, 300470.15 6242377.986, 300425.773 6242435.814, 300383.816 6242520.111, 300355.165 6242614.564, 300369.05 6242618.351)), ((300099.277 6242721.271, 300147.732 6242675.879, 300215.931 6242612.13, 300310.106 6242533.871, 300280.198 6242469.785, 300160.754 6242540.721, 300078.715 6242590.719, 299994.248 6242643.506, 299953.51 6242681.658, 299923.413 6242726.948, 300022.662 6242795.949, 300028.703 6242786.201, 300032.961 6242785.115, 300043.915 6242782.328, 300062.603 6242754.816, 300079.879 6242739.014, 300099.277 6242721.271)), ((283919.921 6245577.146, 283940.992 6245600.608, 283984.864 6245650.333, 284003.853 6245634.752, 284022.915 6245656.625, 284004.343 6245672.171, 284091.347 6245770.904, 284115.8 6245798.648, 284263.98 6245668.389, 284132.235 6245287.2, 284099.836 6245270.839, 283871.388 6245473.339, 283871.221 6245474.168, 283871.424 6245474.993, 283871.925 6245476.57, 283866.128 6245481.675, 283864.819 6245480.647, 283863.824 6245480.424, 283863.048 6245480.806, 283847.359 6245494.486, 283919.921 6245577.146)), ((291668.524 6251540.037, 291666.993 6251543.543, 291674.171 6251560.722, 291676.43 6251561.159, 291686.394 6251585.09, 291685.554 6251587.091, 291695.624 6251610.858, 291697.706 6251611.769, 291707.91 6251635.317, 291707.079 6251637.34, 291717.349 6251661.311, 291719.396 6251662.066, 291720.35 6251664.617, 291722.997 6251663.776, 291726.21 6251666.298, 291729.241 6251664.856, 291730.205 6251666.896, 291740.902 6251662.492, 291739.673 6251659.414, 291747.42 6251656.532, 291748.4 6251659.128, 291755.568 6251656.034, 291761.183 6251669.361, 291763.161 6251669.948, 291773.424 6251693.763, 291772.61 6251695.854, 291782.732 6251719.788, 291784.83 6251720.388, 291795.013 6251744.091, 291794.035 6251746.044, 291804.266 6251770.081, 291806.288 6251770.769, 291816.649 6251794.785, 291815.76 6251796.941, 291826.023 6251820.778, 291827.978 6251821.586, 291838.242 6251845.368, 291837.412 6251847.369, 291846.853 6251871.111, 291849.648 6251872.027, 291859.651 6251895.081, 291858.862 6251897.294, 291868.936 6251920.883, 291871.077 6251921.629, 291881.066 6251945.36, 291880.301 6251947.718, 291890.615 6251971.379, 291892.798 6251972.303, 291902.882 6251995.937, 291902.011 6251998.059, 291912.345 6252021.665, 291906.476 6252187.934, 292112.989 6252195.079, 291483.633 6251076.914, 291436.366 6251099.723, 291439.58 6251106.806, 291452.664 6251100.702, 291467.176 6251136.295, 291619.1 6251490.508, 291636.082 6251483.168, 291643.867 6251501.77, 291656.94 6251532.97, 291664.322 6251529.814, 291668.524 6251540.037)), ((287329.752 6252608.105, 287217.367 6252386.214, 287210.601 6252372.469, 287169.215 6252285.945, 287159.609 6252279.527, 287071.72 6252324.055, 287065.927 6252401.689, 287029.692 6252399.447, 287001.92 6252780.545, 287158.668 6252701.062, 287165.927 6252693.191, 287169.315 6252691.591, 287177.393 6252691.405, 287327.603 6252615.169, 287329.752 6252608.105)), ((298870.802 6256180.465, 298856.464 6256188.883, 298865.227 6256203.67, 298879.566 6256195.251, 298870.802 6256180.465)), ((286805.006 6258565.516, 286905.189 6258712.52, 287186.455 6258464.23, 287074.933 6258348.268, 286999.844 6258405.068, 287000.285 6258405.633, 286998.916 6258410.496, 286996.609 6258412.186, 286993.133 6258414.728, 286988.843 6258414.332, 286988.312 6258413.643, 286807.105 6258551.615, 286805.006 6258565.516)), ((276015.29 6272411.027, 275970.936 6272344.35, 275949.261 6272359.812, 275911.316 6272386.867, 275956.16 6272452.035, 276015.29 6272411.027)), ((303272.046 6221021.959, 302940.739 6220781.883, 302811.547 6220961.192, 303143.314 6221197.565, 303145.459 6221199.097, 303272.046 6221021.959)), ((307781.056 6222066.906, 307855.293 6222172.141, 307947.406 6222105.862, 307892.383 6222025.363, 307837.057 6221946.211, 307811.515 6221909.663, 307702.711 6221982.645, 307781.056 6222066.906)), ((304114.966 6223923.305, 304176.036 6224003.276, 304370.088 6223857.949, 304301.996 6223802.322, 304114.966 6223923.305)), ((311123.398 6244595.456, 311086.271 6244566.758, 311065.825 6244585.578, 311046.82 6244569.256, 311017.765 6244594.018, 311030.111 6244614.545, 311011.805 6244633.696, 311004.505 6244642.16, 311081.954 6244667.889, 311123.398 6244595.456)), ((310958.952 6244895.655, 311012.514 6244790.789, 310953.139 6244738.981, 310880.693 6244845.079, 310958.952 6244895.655)), ((310325.773 6245766.994, 310329.95 6245769.053, 310359.285 6245778.648, 310384.27 6245723.584, 310352.109 6245712.812, 310373.853 6245673.616, 310339.729 6245674.099, 310319.235 6245740.503, 310319.966 6245750.702, 310321.716 6245756.174, 310326.764 6245760.901, 310325.773 6245766.994)), ((311154.141 6247343.606, 311115.214 6247304.3, 311126.013 6247410.236, 311136.337 6247440.076, 311162.858 6247478.891, 311167.13 6247475.747, 311181.182 6247480.476, 311216.62 6247470.063, 311229.81 6247456.757, 311195.429 6247388.396, 311154.141 6247343.606)), ((311470.481 6253781.547, 311376.622 6253747.069, 311351.918 6253784.145, 311438.511 6253830.251, 311470.481 6253781.547)), ((303580.594 6257251.298, 303625.997 6257138.942, 303584.015 6257151.402, 303561.78 6257158, 303458.899 6257203.321, 303580.594 6257251.298)), ((311431.217 6264167.735, 311397.648 6264149.01, 311370.785 6264137.474, 311259.077 6264097.158, 311250.113 6264198.55, 311448.707 6264270.026, 311475.376 6264279.218, 311547.217 6264304.389, 311551.94 6264236.007, 311461.286 6264180.71, 311431.217 6264167.735)), ((311765.508 6264535.872, 311711.789 6264536.788, 311714.51 6264594.366, 311776.307 6264587.052, 311765.508 6264535.872)), ((311719.971 6264696.286, 311821.069 6264694.074, 311800.5 6264651.854, 311785.456 6264609.111, 311779.56 6264605.411, 311714.899 6264605.634, 311719.971 6264696.286)), ((313133.725 6264875.73, 313141.165 6264763.591, 313119.327 6264595.984, 313114.063 6264540.998, 313117.018 6264507.43, 313132.804 6264470.883, 313144.084 6264448.594, 313147.934 6264384.899, 313159.438 6264375.794, 313163.041 6264364.049, 313149.643 6264351.561, 313043.665 6264333.434, 312792.823 6264288.537, 312545.596 6264282.445, 312518.117 6264383.429, 312516.605 6264528.89, 312544.714 6264529.475, 312541.783 6264584.345, 312513.596 6264582.56, 312512.057 6264645.878, 312547.015 6264644.09, 312547.146 6264627.496, 312597.443 6264627.64, 312592.111 6264577.234, 312619.762 6264574.725, 312630.346 6264697.114, 312649.432 6264913.904, 312576.694 6264922.229, 312533.571 6264927.696, 312520.804 6264944.885, 312526.837 6265036.565, 312530.757 6265046.039, 312540.572 6265058.857, 312561.514 6265074.733, 312571.505 6265079.012, 312590.412 6265078.151, 312666.612 6265071.969, 312736.116 6265096.219, 312750.138 6265097.736, 313008.925 6265073.106, 313022.622 6265071.765, 313074.63 6265062.765, 313151.234 6265048.676, 313213.257 6265042.212, 313206.06 6264971.801, 313212.146 6264870.585, 313133.725 6264875.73)), ((310838.087 6265269.483, 310773.822 6265275.633, 310771.037 6265340.913, 310842.76 6265334.911, 310838.087 6265269.483)), ((314533.695 6268847.952, 314288.876 6268762.991, 314249.733 6268870.665, 314258.095 6268888.4, 314262.789 6268889.723, 314238.584 6268996.444, 314244.905 6269003.744, 314373.489 6269068.134, 314426.125 6269059.748, 314456.411 6269075.434, 314533.695 6268847.952)), ((305937.56 6272404.538, 306035.675 6272415.634, 306048.041 6272295.619, 305986.429 6272277.185, 305958.372 6272268.285, 305947.885 6272307.902, 305929.656 6272394.481, 305937.56 6272404.538)), ((314098.126 6273995.797, 313910.298 6274032.012, 313941.793 6274187.862, 313955.985 6274189.957, 314083.609 6274170.201, 314173.966 6274139.937, 314178.44 6274063.242, 314098.126 6273995.797)), ((314396.114 6274668.366, 314388.343 6274680.618, 314369.397 6274836.798, 314567.845 6274753.941, 314674.644 6274584.594, 314750.665 6274372.561, 314633.766 6274292.021, 314471.517 6274549.456, 314396.114 6274668.366)), ((314091.904 6275313.365, 314104.581 6275314.165, 314111.638 6275287.122, 314100.43 6275284.73, 314108.85 6275245.266, 314127.118 6275249.647, 314137.773 6275206.875, 314104.958 6275195.711, 314089.34 6275195.341, 314075.351 6275191.853, 313997.707 6275159.383, 313985.237 6275186.632, 313894.448 6275145.486, 313857.301 6275232.208, 313910.417 6275255.838, 313927.145 6275285.084, 313998.037 6275318.855, 314016.442 6275326.212, 314031.264 6275286.794, 314091.904 6275313.365)), ((314304.624 6280495.838, 314280.887 6280478.949, 314191.227 6280570.537, 314231.495 6280615.891, 314247.712 6280616.482, 314304.624 6280495.838)), ((313858.383 6280675.163, 313821.091 6280723.508, 313832.551 6280735.756, 313860.031 6280763.547, 313889.968 6280767.111, 313921.333 6280735.247, 313893.032 6280692.309, 313865.805 6280658.2, 313858.383 6280675.163)))
Written → landuse_dissolved.geoparquet
0:59
Now let me verify the final output properly.
0:59
Bash
cd /work && python -c "
cd /work && python -c "
import geopandas as gpd
gdf = gpd.read_parquet('landuse_dissolved.geoparquet')
print('Rows:', len(gdf))
print('Columns:', gdf.columns.tolist())
print()
print('All MultiPolygon?', (gdf.geometry.type == 'MultiPolygon').all())
print('CRS:', gdf.crs.to_epsg())
print()
print(gdf[['class','area_m2','parcel_count']].head(15).to_string())
print()
print('Area range: {:.2f} – {:.2f} m²'.format(gdf['area_m2'].min(), gdf['area_m2'].max()))
print('Count range: {} – {}'.format(gdf['parcel_count'].min(), gdf['parcel_count'].max()))
print('Total landuse classes:', len(gdf))
"
Rows: 72
Columns: ['class', 'area_m2', 'parcel_count', 'geometry']
All MultiPolygon? True
CRS: 32734
class area_m2 parcel_count
0 airfield 2.444056e+06 1
1 allotments 1.715652e+04 215
2 animal_keeping 6.636804e+05 302
3 barracks 1.873189e+03 4
4 base 9.244053e+05 1
5 beach_resort 2.936896e+05 1
6 brownfield 1.418610e+05 13
7 bunker 6.712463e+04 638
8 camp_site 8.568784e+05 13
9 cemetery 4.515795e+06 65
10 clinic 9.552029e+04 19
11 college 1.178636e+07 37
12 commercial 7.190500e+06 327
13 construction 5.727714e+06 84
14 doctors 1.407718e+02 1
Area range: 140.77 – 1700275799.23 m²
Count range: 1 – 8476
Total landuse classes: 72
1:04
Everything looks good. Let me verify the output file exists and clean up.
1:04