tmaptools | Tools for thematic maps | Map library
kandi X-RAY | tmaptools Summary
kandi X-RAY | tmaptools Summary
tmaptools: tools for thematic maps in R ===. [AppVeyor Build Status] Status([Downloads] This package offers a set of handy tool functions for reading and processing spatial data. The aim of these functions is to supply the workflow to create thematic maps, e.g. read shape files, set map projections, append data, calculate areas and distances, and query OpenStreetMap. The visualization of thematic maps can be done with the [tmap] package.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of tmaptools
tmaptools Key Features
tmaptools Examples and Code Snippets
Community Discussions
Trending Discussions on tmaptools
QUESTION
I have folder where many lidar(.las) files. It looks like
...ANSWER
Answered 2022-Apr-17 at 11:33Maybe somthing like this
QUESTION
Lidar data is simply 3d coordinates, usually in las
file format. Сontent example
ANSWER
Answered 2022-Mar-19 at 08:58Please find below one possible solution to get a data.table,data.frame
with all the information. You can use as.data.frame()
to get a pure data.frame
but a data.table
is a data.frame
Reprex
NB: I used a .las
dataset built in the lidR
library as it is more convenient.
- The example dataset from
lidR
QUESTION
I am trying to get a raster layer (5-metre Digital Elevation Model (DEM)) from the Australian government through the ArcGIS REST API
url: https://services.ga.gov.au/site_9/rest/services/DEM_LiDAR_5m/MapServer/
I can perform a query for the boundary and footprint layers with good results
boundary query:
"https://services.ga.gov.au/site_9/rest/services/DEM_LiDAR_5m/MapServer/1/query?where=&text=&objectIds=&time=&geometry=xmin:133.226100657682, ymin:-23.6165145646468, xmax:133.235899342318, ymax:-23.6074854353532&geometryType=esriGeometryEnvelope&inSR=4283&spatialRel=esriSpatialRelEnvelopeIntersects&relationParam=&outFields=&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=json"
response (plotted in R):
R plot through jsonlite response
Footprint query:
"https://services.ga.gov.au/site_9/rest/services/DEM_LiDAR_5m/MapServer/2/query?where=&text=&objectIds=&time=&geometry=xmin:133.226100657682, ymin:-23.6165145646468, xmax:133.235899342318, ymax:-23.6074854353532&geometryType=esriGeometryEnvelope&inSR=4283&spatialRel=esriSpatialRelEnvelopeIntersects&relationParam=&outFields=&returnGeometry=true&maxAllowableOffset=&geometryPrecision=&outSR=&returnIdsOnly=false&returnCountOnly=false&orderByFields=&groupByFieldsForStatistics=&outStatistics=&returnZ=false&returnM=false&gdbVersion=&returnDistinctValues=false&f=json"
response:
where I got the name of TIF files I am looking for, nevertheless all my queryes to the raster layer: https://services.ga.gov.au/site_9/rest/services/DEM_LiDAR_5m/MapServer/3 does not give me any result
I have tried the rcran package "arcpullr" as well, but no results
any help?
...ANSWER
Answered 2022-Jan-04 at 17:01So most likely data provider has disabled the query operation on the 3rd layer of that map service. Also, no fields are enabled on the layer 3, so there is nothing to query or return through a query operation.
So only export operation would work on that by providing a bbox (which you can use also by using the results of the footprint layer).
QUESTION
I have a map with an elevation raster that is in lat/long coordinates but I now need to display the map in easting/northing. How can I accomplish this?
I have tried reprojecting the raster from lat/long to UTM but this warps the map (I assume for reasons discussed in this SO post).
A minimal working example follows a description of the code that I am using to produce the map in lat/long coordinates. I used a manually defined bounding box, extent
, to download the elevation raster of interest from FedData
. I then plotted the raster using tmap
.
ANSWER
Answered 2021-Nov-13 at 19:47I now need to display the map in easting/northing.
I understand that in stead of angular (lon/lat) coordinates you want to use planar (Cartesian) coordinates. That means that you need to choose an appropriate coordinate reference system (CRS). You say you used UTM, and that could be reasonable, but you found that the results are "warped". You should show the code you used because you probably made a mistake. There always is some distortion, but for a small area like this is would not be an issue if you specify the CRS correctly. (otherwise, explain "warped" and why it matters.)
For example
QUESTION
I would like to record a series of maps using the sf and tmap packages in R. My data is an sf object with different attributes linked to square polygons. The breaks for the maps are the same for each attribute that I want to map, that's why I thought of coding a simple loop.
The code below will give you a sample of my data. Sorry, the dput is a bit long, it's because sf objects integrate geometries.
...ANSWER
Answered 2021-Sep-21 at 12:47You just have to run the following lines of code and it should work.
QUESTION
I'm trying to work out how to create boundary boxes from sf point geometry data on every row in an sf object. I'm trying to use the 'bb' function from the tmaptools package, along with dplyr and rowwise(). However, the output I get is just the same bounday box values copied onto every row, rather than a specific boundary box calculated from the point data on each row.
Here is a snip of the data frame sf object:
...ANSWER
Answered 2021-Sep-02 at 20:18You made it unnecessarily complicated by storing vectors in a data frame.
It's better to store this data in tibble
with x
and y
columns.
See below.
I'm using tribble
and bind_cols
here to make it more visible.
QUESTION
I am trying to add some pie charts inside a map in the following way:
...ANSWER
Answered 2021-May-29 at 01:03Add border.lwd = NA
as an argument to tm_symbols()
. The documentation states:
border.lwd: line width of the symbol borders. If NA, no symbol borders are drawn.
QUESTION
I am building a shiny app and I want to have a static dashboardHeader()
title with a logo to the right of it. I have looked through stackoverflow to figure out how to do this and it seems like this requires HTML tags. I am not a computer programmer - just an R user, so I don't really understand how these work. But following advice of others, it seems like I need tag$li()
to set the the height of the header bar and the logo. When I run the app, the header appears as I want in the RStudio shiny viewer, but when I view it in a browser (Chrome), the title is sunken below the logo and cut off. Below is a reproducible example. You will first need to download the [R logo] https://www.r-project.org/logo/Rlogo.png and save it as "Rlogo.png" in a subdirectory called "www" in the same directory as the code below (which in turn must be saved as "app.R"):
ANSWER
Answered 2021-Mar-29 at 20:00After some trial and error and a lot of Googling, I think that basically this issue is that this is a "hack" (to use programmers' parlance) to get around how shinydashboard
works. I found out that to get both the logo and the title to display the use of tags$li(class = "dropdown")
creates a dropdown list, and because the title was the second element of the list it necessarily had to go below the logo. So I "hacked" that "hack!" In the call to tags$h1()
I found out it is possible to specify a negative value for the margin. By setting this to -50px, I got my desired output. I am sure a real computer programmer who actually understands HTML and CSS can give a much more elegant solution. For fellow R users who aren't programmers, here is the reproducible code with my "hacking-the-hack" solution. Same caveats about downloading the image, saving it to the www subdirectory and saving the script as app.R as in my question apply here:
QUESTION
I am building a Shiny app that provides canned reports and maps from a database of field-collected vegetation data. The app has a series of SQL scripts that draw in the data from appropriate database tables to generate the reports and to query the spatial data stored as blobs. The user interface allows the user to select a project and then a unit within that project on which to report. When my app runs, Shiny freezes when I try to change one of the projects. I suspect that this has to do either with how I have set up the reactivity to update the "Unit" drop down menu, or the interface between R and MS SQL. Unfortunately, I was unable to recreate the problem outside of my organization's enterprise data, so I will present two scripts which will hopefully be enough information. My apologies ahead of time for not being able to come up with a script that reproduces the error. Below is a working minimal reproducible example of how I have structured the app - this one works without error, but will give you a sense of how I have built the app and how it should work:
...ANSWER
Answered 2021-Mar-24 at 21:57This turned out to be an issue with an SQL script that I read into my Shiny server function. It was a lesson in making sure all helping scripts are running properly before sourcing them into Shiny.
QUESTION
I am trying plot county level maps. I came across a tutorial that uses the sf
package and the tmap
package. Using ?st_read
, it shows an example of how to get county level data using North Carolina as an example, using the following code -
nc = st_read(system.file("shape/nc.shp", package="sf"))
I used the code above to plot county level data for NC, however I am not sure how to get the data for other states. I have tried replacing the nc.shp
with sc.shp
or va.shp
, etc, however I get the following error - Error: Fill argument neither colors nor valid variable name(s)
.
How do I extract the data for other states, or preferable "all" states. I would like to be able to plot the map for the entire US, regionally (north, south, east, west) and also multiple states within a region.
Here is some reproducible code for the map I created -
...ANSWER
Answered 2021-Feb-20 at 01:17The 'nc' data is included as example data with the sf
package, so you'll have to get data for other states in another manner.
There are a few ways to get county & state level shapefiles to plot. Urbnmapr (https://github.com/UrbanInstitute/urbnmapr) is the one I used below.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install tmaptools
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page