Comments (10)
Thanks a lot, that unlocks some key aspect of my problem ! I'll dig it further and let you know.
from mapedit.
also asked the question in SO, there
from mapedit.
See also these two threads
leaflet currently does not render raster images with arbitrary or no crs. In an early version of mapview we circumvented this with the approach you mention via scaling the coordinates to lie between 0 and 1. However, I agree that this is not a solution, especially for digitizing.
One hope I have is that whenever leaflet gets updated to leafletjs 1.x this issue will be resolved. @timelyportfolio have you ever tested whether rasters work with L.CRS.Simple
in the leaflet 1.x branch? Or would it be possible to enable editMap
to work with mapview::plainview
which is used when native.crs = TRUE
?
mapview(r, native.crs = TRUE)
from mapedit.
Hi @tim-salabim and @timelyportfolio (me again!)
With mapview(r, native.crs=TRUE)
I got the (seen-elsewhere) following error:
Error in round(size) : non-numeric argument to mathematical function
In addition: Warning message:
In rasterCheckSize(x, maxpixels = maxpixels) :
maximum number of pixels for Raster* viewing is #BEBEBE80 ;
the supplied Raster* has 100520
... decreasing Raster* resolution to #BEBEBE80 pixels
to view full resolution set 'maxpixels = 100520 '
plainview(r)
works though, and if we could do the same things that we do with a regular editmap
I think the main problem would be solved!
from mapedit.
This has been fixed recently, see r-spatial/mapview#111
So if you install mapview from github you should be able to use native.crs = TRUE
devtools::install_github("r-spatial/mapview@develop")
from mapedit.
indeed!
from mapedit.
@timelyportfolio may I ping you to have your feeling about what @tim-salabim suggested? Cheers!
from mapedit.
Sure, feel free to ping me. Might be a little slower in responding over the holidays. Cheers!
from mapedit.
@timelyportfolio , that was a question, perhaps too politely asked ;-)
from mapedit.
Ok, I understand now. I very likely am headed down the wrong path, so feel free to set me straight.
-
addRasterImage()
creates a tile layer. Is this necessary, or is theL.imageOverlay
as in example sufficient? -
This might be helpful down the road Leaflet/Leaflet.draw#611.
Some code as a demonstration of the very little that I accomplished.
library(jpeg)
library(raster)
library(leaflet)
library(leaflet.extras)
library(mapview)
library(mapedit)
# dl an image
path <- "https://upload.wikimedia.org/wikipedia/commons/thumb/5/58/CheHigh.jpg/280px-CheHigh.jpg"
che <- tempfile()
download.file(path, che, mode="wb")
im <- jpeg::readJPEG(che)
# prepare a raster from it
r <- raster(xmn=0, xmx=1,
ymn=0, ymx=nrow(im)/ncol(im),
ncols=ncol(im), nrows=nrow(im))
r <- setValues(r, as.numeric(t(im)))
# prepare the leaflet
lf <- leaflet(
options = leafletOptions(
crs = leafletCRS("L.CRS.Simple"),
minZoom = 1,
maxZoom = 10
)
) %>%
setView(0, 0, zoom=3)
lf2 <- htmlwidgets::onRender(
lf,
sprintf(
"
function(el, x) {
var map = this;
var w = %s,
h = %s,
url = 'http://upload.wikimedia.org/wikipedia/commons/thumb/5/58/CheHigh.jpg/280px-CheHigh.jpg';
// calculate the edges of the image, in coordinate space
var southWest = map.unproject([0, h], 3);
var northEast = map.unproject([w, 0], 3);
var bounds = new L.LatLngBounds(southWest, northEast);
L.imageOverlay(url, bounds).addTo(map);
}
",
dim(im)[2],
dim(im)[1]
)
)
editMap(lf2)
leaflet.extras
uses layer.toGeoJSON()
which does not gives projected coordinates unfortunately (or at least I think unfortunately). I believe we might need map.latLngToLayerPoint
instead.
I know this isn't much, but maybe it will get us one step further towards something usable.
from mapedit.
Related Issues (20)
- Exporting selected map data in Shiny HOT 3
- Edit existing feature within Shiny and save HOT 7
- Is there a way of flushing the old data from $finished when using singleFeature=TRUE mapedit in a Shiny app? HOT 9
- Load back previously drawn polygons to mapedit map
- editor Module in demo example fails in mapedit 0.6.0 but works in 0.5.0 HOT 2
- selectFeatures draws on world map even if crs = NA (for mode = "click" only) HOT 7
- New feature to download edited data HOT 2
- Click events for leafpm editToolbar buttons HOT 5
- leafpm removes markers added using leafletProxy HOT 2
- Use raster in base map with editMap HOT 2
- Issues installing r-spatial packages HOT 1
- is there a way to display only some of the tools HOT 2
- Is this package still actively developed? HOT 1
- Strange case of difficult viewing HOT 7
- Integration leafmap new feature HOT 17
- 'initBaseMaps' and 'mode = "click"' for selectFeatures
- Warning: `select_()` was deprecated in dplyr 0.7.0. HOT 5
- selectFeatures error possibly related to "draw" mode HOT 3
- mapedit installation on Google colab
- Error triggered by "Clear All" when there are three or more drawn objects.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mapedit.