Steps to create spatial plots

18 views
Skip to first unread message

lily li

unread,
Jan 15, 2018, 5:22:15 PM1/15/18
to R mailing list, ggp...@googlegroups.com
Hi users,

I have no clear clue about plotting spatial data. For example, I just have a table with attribute values of each grid cell, such as elevation. Then I have coordinates of the upper left corner in UTM, the number of rows and columns, and grid cell size. How to create spatial plot of elevations for the grid cells, in color ramp? Should I create a spatial grid layer with all the polygons first? Thanks.

Roman Luštrik

unread,
Jan 15, 2018, 5:27:32 PM1/15/18
to lily li, R mailing list, ggplot2
You will need to coerce your data into a "spatial" kind, as implemented in `sp` or as of late, `sf` packages. You might want to give the vignettes a whirl before you proceed.
Roughly, you will have to coerce the data to Spatial* (you could go for a point, raster or grid type, I think) and also specify the projection. Once you have that, plotting should be handled by packages.

Here are a few quick links that might come handy:



Cheers,
Roman

On Mon, Jan 15, 2018 at 11:22 PM, lily li <choc...@gmail.com> wrote:
Hi users,

I have no clear clue about plotting spatial data. For example, I just have a table with attribute values of each grid cell, such as elevation. Then I have coordinates of the upper left corner in UTM, the number of rows and columns, and grid cell size. How to create spatial plot of elevations for the grid cells, in color ramp? Should I create a spatial grid layer with all the polygons first? Thanks.

--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+unsubscribe@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
In God we trust, all others bring data.

Adriano Fantini

unread,
Jan 16, 2018, 2:07:20 AM1/16/18
to Roman Luštrik, lily li, R mailing list, ggplot2
the latest ggplot from github (to be installed with `devtools:install_github()`) has support for SF objects too, it's a treat!
However, sf is not exactly designed for raster data. Of course you can make each of your cells be a square polygon, but it's not the most efficient way for big datasets. For this the `raster` (excellent and rock stable) and `stars` (even more excellent, but in heavy development) can be used.

Adriano Fantini
Reply all
Reply to author
Forward
0 new messages