基于指定等深线与纬度范围在QGIS中生成多边形的技术求助
How to Create a Closed Polygon in QGIS Using Isobaths and Latitude Boundaries
Hey there! Let's break down exactly how to generate your desired closed polygon in QGIS, using your two isobaths as side boundaries and the 33°S/43°S latitudes as north/south edges. Here's a step-by-step workflow that’s easy to follow:
1. Prep Your Input Data
First, make sure all your line layers are ready to work with:
- Your two isobath lines (they need to be vector line layers, not raster data)
- The 33°S and 43°S latitude lines. If you don’t have these already:
- You can create a new line shapefile layer, then use the digitizing toolbar to draw the latitudes. Or use the Virtual Layer tool with a simple SQL query to generate them automatically:
SELECT ST_SetSRID(ST_MakeLine(ST_Point(-180, -33), ST_Point(180, -33)), 4326) AS geometry UNION ALL SELECT ST_SetSRID(ST_MakeLine(ST_Point(-180, -43), ST_Point(180, -43)), 4326) AS geometry - Pro tip: Ensure all layers use the same coordinate reference system (CRS). A projected CRS (like UTM zones) works better here than geographic WGS84 to avoid distortion issues.
- You can create a new line shapefile layer, then use the digitizing toolbar to draw the latitudes. Or use the Virtual Layer tool with a simple SQL query to generate them automatically:
2. Align Line Endpoints to Form a Closed Loop
This is the most critical step—your four lines need to connect end-to-end to form a single, unbroken ring:
- Enable the Snapping Toolbar (right-click the toolbar area and check "Snapping Toolbar")
- Set snapping to "Vertex" mode for all four line layers, with a small tolerance (adjust based on your CRS; 10 meters is a good starting point)
- Enter Edit Mode for each line layer one by one:
- For each isobath, move its northern endpoint to snap exactly to the corresponding point on the 33°S latitude line
- Move its southern endpoint to snap exactly to the corresponding point on the 43°S latitude line
- Trim the 33°S and 43°S lines so they only span between the two isobaths (use the Trim/Extend Features tool in the digitizing toolbar to cut off excess segments outside your isobaths)
3. Merge All Boundary Lines into One Layer
Once all endpoints are connected and lines are trimmed to the right length:
- Use the Merge Vector Layers tool (found under
Processing > Toolbox > Vector general > Merge Vector Layers) - Select your two isobath layers and the two trimmed latitude layers as inputs
- Save the merged output as a new line layer
4. Convert the Closed Line Ring to a Polygon
Now turn that closed line loop into a solid polygon:
- Use the Lines to Polygons tool (under
Processing > Toolbox > Vector geometry > Lines to Polygons) - Select your merged line layer as the input
- Save the output as a new polygon layer—this is your desired closed polygon!
Quick Troubleshooting Tips
- If the polygon doesn’t form, double-check that all line endpoints are fully snapped (no gaps or overlaps between segments)
- If you end up with multiple polygons, make sure your merged lines form exactly one continuous closed ring (no extra, unconnected line segments)
内容的提问来源于stack exchange,提问作者Alfonsina López




