Platform
Resources
Pricing
Sign in
Get started
Daniel J. Dufour
Conflict Resolution, GIS, Tacos
Workspace
Fork
Published
By
Daniel J. Dufour
Edited
Oct 12, 2021
Insert cell
#
Convert GeoTIFF to PNG using GeoRaster
Insert cell
import
{
file
}
from
"@jashkenas/inputs"
Insert cell
parseGeoRaster
=
require
(
"georaster"
)
Insert cell
viewof
geotiff
=
file
(
{
title
:
"file.tif"
,
description
:
"upload a GeoTIFF"
,
multiple
:
false
,
}
)
Insert cell
arrayBuffer
=
await
Files
.
buffer
(
geotiff
)
Insert cell
georaster
=
parseGeoRaster
(
arrayBuffer
)
Insert cell
height_over_width
=
georaster
.
height
/
georaster
.
width
Insert cell
height
=
height_over_width
>=
1
?
512
:
Math
.
round
(
512
/
height_over_width
)
;
Insert cell
width
=
height_over_width
<=
1
?
512
:
Math
.
round
(
512
/
height_over_width
)
;
Insert cell
canvas
=
georaster
.
toCanvas
(
{
height
,
width
}
)
Insert cell
saveFile
=
require
(
"easy-file-saver"
)
.
catch
(
(
)
=>
window
[
'saveFile'
]
)
Insert cell
saveFile
(
{
data
:
canvas
,
filename
:
"overview.png"
}
)
Insert cell
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Try it for free
Learn more
Fork
View
Export
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
parseGeoRaster
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
geotiff
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
arrayBuffer
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
georaster
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
height_over_width
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
height
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
width
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
canvas
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
saveFile
Add comment
Copy import
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML
Add comment
Select
Duplicate
Copy link
Embed
Delete
JavaScript
Markdown
HTML