Overlay Operations: Intersection, Union, Difference
Overlay operations are a core set of tools in geospatial analysis that enable you to combine, compare, and manipulate spatial datasets based on their geometries. These operations—intersection, union, and difference—allow you to answer questions such as "Where do two datasets overlap?", "What is the combined area covered by two layers?", or "What areas are unique to one layer compared to another?" In GIS, overlay operations are essential for tasks like land use analysis, environmental impact studies, and resource management. By leveraging overlay techniques, you can extract new spatial features and attribute information from existing datasets, forming the backbone of many spatial analyses.
123456789101112131415import geopandas as gpd from shapely.geometry import Polygon # Create two simple polygon GeoDataFrames poly1 = Polygon([(0, 0), (2, 0), (2, 2), (0, 2)]) poly2 = Polygon([(1, 1), (3, 1), (3, 3), (1, 3)]) gdf1 = gpd.GeoDataFrame({'geometry': [poly1]}, crs="EPSG:4326") gdf2 = gpd.GeoDataFrame({'geometry': [poly2]}, crs="EPSG:4326") # Compute the intersection intersection = gpd.overlay(gdf1, gdf2, how='intersection') print("Intersection result:") print(intersection)
12345678910111213141516import geopandas as gpd from shapely.geometry import Polygon # Define two polygons poly_a = Polygon([(0, 0), (2, 0), (2, 2), (0, 2)]) poly_b = Polygon([(1, 1), (3, 1), (3, 3), (1, 3)]) gdf_a = gpd.GeoDataFrame({'geometry': [poly_a]}, crs="EPSG:4326") gdf_b = gpd.GeoDataFrame({'geometry': [poly_b]}, crs="EPSG:4326") # Perform a union overlay union = gpd.overlay(gdf_a, gdf_b, how='union') print("Union result:") print(union) # The resulting geometry includes all areas covered by either of the input polygons, combining their extents and attributes.
Merci pour vos commentaires !
Demandez à l'IA
Demandez à l'IA
Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion
Can you explain the difference between intersection and union in overlay operations?
What are some practical applications of these overlay techniques in GIS?
How does the 'difference' operation work compared to intersection and union?
Génial!
Completion taux amélioré à 7.69
Overlay Operations: Intersection, Union, Difference
Glissez pour afficher le menu
Overlay operations are a core set of tools in geospatial analysis that enable you to combine, compare, and manipulate spatial datasets based on their geometries. These operations—intersection, union, and difference—allow you to answer questions such as "Where do two datasets overlap?", "What is the combined area covered by two layers?", or "What areas are unique to one layer compared to another?" In GIS, overlay operations are essential for tasks like land use analysis, environmental impact studies, and resource management. By leveraging overlay techniques, you can extract new spatial features and attribute information from existing datasets, forming the backbone of many spatial analyses.
123456789101112131415import geopandas as gpd from shapely.geometry import Polygon # Create two simple polygon GeoDataFrames poly1 = Polygon([(0, 0), (2, 0), (2, 2), (0, 2)]) poly2 = Polygon([(1, 1), (3, 1), (3, 3), (1, 3)]) gdf1 = gpd.GeoDataFrame({'geometry': [poly1]}, crs="EPSG:4326") gdf2 = gpd.GeoDataFrame({'geometry': [poly2]}, crs="EPSG:4326") # Compute the intersection intersection = gpd.overlay(gdf1, gdf2, how='intersection') print("Intersection result:") print(intersection)
12345678910111213141516import geopandas as gpd from shapely.geometry import Polygon # Define two polygons poly_a = Polygon([(0, 0), (2, 0), (2, 2), (0, 2)]) poly_b = Polygon([(1, 1), (3, 1), (3, 3), (1, 3)]) gdf_a = gpd.GeoDataFrame({'geometry': [poly_a]}, crs="EPSG:4326") gdf_b = gpd.GeoDataFrame({'geometry': [poly_b]}, crs="EPSG:4326") # Perform a union overlay union = gpd.overlay(gdf_a, gdf_b, how='union') print("Union result:") print(union) # The resulting geometry includes all areas covered by either of the input polygons, combining their extents and attributes.
Merci pour vos commentaires !