geojsonio | Convert many data formats to & from GeoJSON & TopoJSON | Map library
kandi X-RAY | geojsonio Summary
kandi X-RAY | geojsonio Summary
Convert many data formats to & from GeoJSON & TopoJSON
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 geojsonio
geojsonio Key Features
geojsonio Examples and Code Snippets
Community Discussions
Trending Discussions on geojsonio
QUESTION
I'm trying to read a topojson into R for ggplot2 use. It seems the rgdal
package is being retired, so I'm trying to use st_read
in the sp
package, but I just get a big box and that's all. It looks like the fields I get are about right, but it's definitely not getting the whole thing in there correctly. It says it only has one feature and two fields. Any idea what I might be doing wrong? Thanks.
I tried following these directions, but nothing seemed to work:
R - Import html/json map file to use for heatmap https://www.r-bloggers.com/2014/09/overcoming-d3-cartographic-envy-with-r-ggplot/
I can give an example file---I know it works, because we do use it and are able to show it with D3, but I want to be able to show it using ggplot2.
Example code that doesn't work:
...ANSWER
Answered 2022-Mar-19 at 00:32These files can be opened in R with some help from mapshaper.org. I used the online upload, but there's a command line tool as well.
Use mapshaper to export the file as a shapefile. There might be some options to correct the geometries that R has a hard time with, but I'm unfamiliar with mapshaper & it's options. The code below takes care of the problem of invalid geometries pretty well in R. Once converted by mapshaper, you'll have a folder with .dbf, .shp, and .shx files that R's sf
package can read.
QUESTION
I downloaded a geojson file of Iraq's electrical grid from EnergyData. You can download the file yourself here and visit the webpage here
I tried to use geojsonio::geojson_read
to read the file into R, but it threw errors. Another user helpfully pointed out that the file format provided by the Energy Data website is incorrect and does not comply with geojson format, so the filename is misleading. So they recommended I use jsonlite::read_json
. While that function does read the file into R, it's not a spatial object. It's a multi-level list. I also tried sf::st_read
but the object is a messy data frame. I need my final object to be a spatial lines data frame, so I can merge and crop it with another spatial lines objects and write out the resulting shapefile. But when I try sp::SpatialLinesDataFrame
I can't index into the object correctly to connect the lines in the right order. I need the object in R to look like the picture on the web page, and instead its just a hot mess.
Here's my code:
...ANSWER
Answered 2021-Dec-29 at 20:58This is long, because the solution is mostly to dig around and figure out how you want to work with this file. There are a few potential issues here:
- Like I mentioned in your first post, the file might be malformed as far as the structure for a GeoJSON file. Some methods of reading it throw a warning that the last line is incomplete; a trailing empty line is part of the expected structure in json files.
- The
nodes
andinterconnection
attributes are arrays, and I think R functions don't know what to do with those;sf
functions know to read these as list-columns but that might not be available forgeojsonio
ones. - There's a mix of geometry types.
That last point is the big one, because it prevents you from using sp::Spatial*
classes—those are only for single geometry types (SpatialGrid
, SpatialPolygons
, etc.). This file has both points and lines mixed together, so you need something like sf
that can hold mixed geometry types.
A few ways I tried reading this, some of which return lists that you could further dig into, some return sf
objects:
QUESTION
I have a problem with my Shinydashboard: I created a map and i would like to show it only in a menuSubItem (TTTest1) of MenuItem "Test3". As of now, the only content that will be shown is my map and the tabBox "Legend". I assume that the sidebar I have, does not have a real functionality because even if i click on any item of the sidebar, there is no blank page - only my map and a tabBox and nothing really changes, as if it were "static".
Can anyone tell me what went wrong and where i did this (big) mistake?
...ANSWER
Answered 2021-Nov-17 at 14:36You aren't using tabName
correctly. First, you shouldn't reuse tab names in the sidebar
. Those will be clashing. A lot of your menuSubItem
tabs are have repeated values. That should be fixed to something like...
QUESTION
I am trying to filter US the county level shape data set by either FIPS or state. The original data set can be found here. However, I am using a version that has been somewhat cleaned by plotly.
I am able to read the data into R with the following code.
...ANSWER
Answered 2021-Sep-15 at 01:18If you're open to using the package sf and tidyverse-style code, here's a suggestion.
This code reads the geojson into a simple feature collection, then shows how you can filter all counties in state number "04" (looks like Arizona) and plot them.
If you don't want to plot them, of course, just delete those lines :)
QUESTION
I am trying to create a time line plot using leaflet
and leaftime
packages. I want to set custom color in addTimeline
to specify each point to his groups, as follows:
ANSWER
Answered 2021-Jul-03 at 13:34It doesn't seem as if you can pass a vector of colours with the standard styleOptions
, however, an example from the help page for ?addTimeline
show how you can add colours based on the data using a little JavaScript (which thankfully is provided in the example).
Using the example that starts "# to style each point differently based on the data" you need to change it slightly to point to your colour vector e.g. change data.properties.color
to data.properties.color_temp
. Running the code below leads to
QUESTION
I am using R in docker . I have install libraries in docker by using docker hub.but failed . Below is the error i am facing
...ANSWER
Answered 2021-May-26 at 20:43That package has a lot of Linux library dependencies which probably aren't in the image. You can install them by adding these install commands to your Dockerfile.
QUESTION
I am new to working with JSON files so not sure how to go about this. I am trying to plot from the json file for the indigenous territories available from native-lands.ca. I can read the file as JSON but it is not in a format that I can figure out how to plot.
...ANSWER
Answered 2021-May-14 at 06:31It seems your error is similar to what is discussed in a Github issue. A specific number of the input geometries have a Z dimension (not all). As you can see in the following output the arrays have either 2 or 3 dimensions,
QUESTION
I am driving myself crazy and cannot find any answers to this issue. I am trying to map the colour of the polygons (NOT the fill, which I would like to keep transparent) to the factor variable TRAIL_CLASS which has 4 levels. Below is my complete code, which gives the error message "Error: Must request at least one colour from a hue palette." I have also gotten the error "Error in layer(data = data, mapping = mapping, stat = stat, geom = GeomPolygon, : object 'TRAIL_CLASS' not found" when I have tried putting the colour and/or fill outside of the aes function. However when I intentionally set all colours to purple, it has to be outside of the aes function to work properly. Anyways, how would I be able to set the colours of the line based on the TRAIL_CLASS variable?
...ANSWER
Answered 2020-Nov-22 at 21:59The issue is that you use fill=NA
inside aes()
. Simply passing it as argument to geom_polygon
, i.e. outside of aes()
will fix your issue.
QUESTION
I am trying to convert a geojson of London local authorities into a hex cartogram where each hexagon represents one local authority. It works in R but when I try to export the generated hexgrid as geojson or topojson I get the following error:
...ANSWER
Answered 2020-Nov-05 at 22:18You can convert the SpatialPolygonsDataFrame
to sf
, and then write to GeoJSON file with st_write
:
QUESTION
I am trying to create a Choropleth map for Iowa Counties. I downloaded the map data from https://geodata.iowa.gov/dataset/county-boundaries-iowa/resource/183e782f-2d43-4073-8524-fe8e634cf17a
I do get a map, but it is uniform instead of the color I chose from the R brewer palletes nor is it differentiated by data -
...ANSWER
Answered 2020-Jul-30 at 15:48The problem is your second use of addPolygons
.
It needs to have color = ~pal(AREA)
, not fill = ~pal(AREA)
.
fill
is TRUE or FALSE (default TRUE) whether or not they should be filled with your colors.
color
is the actual color/colors to fill with.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install geojsonio
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