|
225 | 225 | "\n",
|
226 | 226 | "<center>\n",
|
227 | 227 | "<figure>\n",
|
228 |
| - " <img src=\"https://scitools.org.uk/cartopy/docs/latest/_images/projections-7.png\">\n", |
| 228 | + " <img src=\"https://scitools.org.uk/cartopy/docs/latest/_images/projections-7.png\" width=\"300\">\n", |
229 | 229 | " <figcaption>Mercator</figcaption>\n",
|
230 | 230 | "</figure>\n",
|
231 | 231 | "</center>\n",
|
232 | 232 | "\n",
|
233 | 233 | "<center>\n",
|
234 | 234 | "<figure>\n",
|
235 |
| - " <img src=\"https://scitools.org.uk/cartopy/docs/latest/_images/projections-2.png\">\n", |
| 235 | + " <img src=\"https://scitools.org.uk/cartopy/docs/latest/_images/projections-2.png\" width=\"400\">\n", |
236 | 236 | " <figcaption>Albers Equal Area</figcaption>\n",
|
237 | 237 | "</figure>\n",
|
238 | 238 | "</center>\n",
|
239 | 239 | "\n",
|
240 | 240 | "<center>\n",
|
241 | 241 | "<figure>\n",
|
242 |
| - " <img src=\"https://scitools.org.uk/cartopy/docs/latest/_images/projections-17.png\">\n", |
| 242 | + " <img src=\"https://scitools.org.uk/cartopy/docs/latest/_images/projections-17.png\" width=\"500\">\n", |
243 | 243 | " <figcaption>Interrupted Goode Homolosine</figcaption>\n",
|
244 | 244 | "</figure>\n",
|
245 | 245 | "</center>\n",
|
246 | 246 | "\n",
|
247 | 247 | "There are literally thousands of different projections out there, and every dataset (or even different images within a single dataset) can have different projections. Even if you correctly georeference images during indexing, if you forget to project them to a common CRS, you can end up with rotated images with nodata values around them, and the images will not be pixel-aligned.\n",
|
248 | 248 | "\n",
|
249 | 249 | "<center>\n",
|
250 |
| - "<img src=\"https://pytorch.org/assets/images/torchgeo-reproject.png\", width=\"800\">\n", |
| 250 | + "<img src=\"https://pytorch.org/assets/images/torchgeo-reproject.png\" width=\"800\">\n", |
251 | 251 | "</center>\n",
|
252 | 252 | "\n",
|
253 | 253 | "We can use a command like:\n",
|
| 254 | + "\n", |
254 | 255 | "```\n",
|
255 | 256 | "$ gdalwarp -s_srs EPSG:5070 -t_srs EPSG:4326 src.tif dst.tif\r",
|
256 | 257 | "```\n",
|
257 |
| - "to reproject a file from one CRS to another.\n" |
| 258 | + "\n", |
| 259 | + "to reproject a file from one CRS to another." |
258 | 260 | ]
|
259 | 261 | },
|
260 | 262 | {
|
|
265 | 267 | "### Resampling\n",
|
266 | 268 | "\n",
|
267 | 269 | "As previously mentioned, each dataset may have its own unique spatial resolution, and even separate bands (channels) in a single image may have different resolutions. All data (including input images and target masks for semantic segmentation) must be resampled to the same resolution. This can be done using GDAL like so:\n",
|
| 270 | + "\n", |
268 | 271 | "```\n",
|
269 | 272 | "$ gdalwarp -tr 30 30 src.tif dst.tif\r",
|
270 | 273 | "```\n",
|
| 274 | + "\n", |
271 | 275 | "Just because two files have the same resolution does not mean that they have *target-aligned pixels* (TAP). Our goal is that every input pixel is perfectly aligned with every expected output pixel, but differences in geolocation can result in masks that are offset by half a pixel from the input image. We can ensure TAP by adding the `-tap` flag:\n",
|
| 276 | + "\n", |
272 | 277 | "```\n",
|
273 | 278 | "$ gdalwarp -tr 30 30 -tap src.tif dst.tif\r",
|
274 |
| - "```\n", |
275 |
| - "\n" |
| 279 | + "```" |
276 | 280 | ]
|
277 | 281 | },
|
278 | 282 | {
|
|
285 | 289 | "Not all geospatial data is raster data. Many files come in vector format, including points, lines, and polygons.\n",
|
286 | 290 | "\n",
|
287 | 291 | "<center>\n",
|
288 |
| - "<img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/6/6b/Bitmap_VS_SVG.svg/2560px-Bitmap_VS_SVG.svg.png\", width=\"500\">\n", |
| 292 | + "<img src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/6/6b/Bitmap_VS_SVG.svg/2560px-Bitmap_VS_SVG.svg.png\" width=\"500\">\n", |
289 | 293 | "</center>\n",
|
290 | 294 | "\n",
|
291 | 295 | "Of course, semantic segmentation requires these polygon masks to be converted to raster masks. This process is called rasterization, and can be performed like so:\n",
|
| 296 | + "\n", |
292 | 297 | "```\n",
|
293 | 298 | "$ gdal_rasterize -tr 30 30 -a BUILDING_HEIGHT -l buildings buildings.shp buildings.tif\r",
|
294 | 299 | "```\n",
|
| 300 | + "\n", |
295 | 301 | "Above, we set the resolution to 30 m/pixel and use the `BUILDING_HEIGHT` attribute of the `buildings` layer as the burn-in value.\n"
|
296 | 302 | ]
|
297 | 303 | },
|
|
0 commit comments