Here-lite: RasterLayer with file tile source - here-api

In the Android Here-lite SDK custom layers are added with the RasterLayer object. In the documented example, custom tiles are taken from an url:
RasterLayer rasterLayer = new RasterLayer(offlineRasterLayerName,
"https://a.tile.openstreetmap.org/{z}/{x}/{y}.png",
19, 1000);
Is it possible to use a file source residing on the local file system instead?
RasterLayer rasterLayer = new RasterLayer(offlineRasterLayerName,
"file://path/to/tiles/{z}/{x}/{y}.png",
19, 1000);
Did not work so far.

Currently it is not possible to use a file source from local system ,as per the documentation it is should be on your own server where you host tiles that you want to show as an overlay on top of selected areas of the world.
RasterLayer(java.lang.String layerName, java.lang.String url, long
maxZoom, long drawOrder)
The format of the URL should be as follows: https://YourRasterTileService.com/zoom/xTile/yTile.png
https://developer.here.com/documentation/android-sdk/api_reference/com/here/sdk/mapviewlite/RasterLayer.html#url
Hope this helps.

Related

Cannot create a RasterLayer object from this file - Chelsa climate tif file

I downloaded Chelsa bio files on my local directory.
And when I tried to create raster for my R project, I keep getting error with following message.
Error in .rasterObjectFromFile(x, band = band, objecttype = "RasterLayer", :
Cannot create a RasterLayer object from this file.
My code was simple and I was able to create worldclim climate raster file with the same code.
and, cannot figure out the difference.
download.file(url = "https://os.zhdk.cloud.switch.ch/envicloud/chelsa/chelsa_V2/GLOBAL/climatologies/1981-2010/bio/CHELSA_bio1_1981-2010_V.2.1.tif",
destfile = "Chelsa/bio1.tif")
bio1 <- raster("Chelsa/bio1.tif")
Could anyone advice on this?
I also tried
bio1 <- stack("Chelsa/bio1.tif")
But, similar error message popped out.
I also changed my directory - instead of putting it under subdirectory (named Chelsa), I directly put the file into my home directory. But, all didn't work.

How to add ArcGIS server layer using leaflet.esri package?

I am trying to add a layer from a published ArcGIS service feature into a leaflet map in R using the leaflet.esri package.
I've read the documentations here https://rdrr.io/cran/leaflet.esri/man/addEsriTiledMapLayer.html and here https://cran.r-project.org/web/packages/leaflet.esri/leaflet.esri.pdf and have tested the examples
My code looks like this:
library(leaflet)
library(leaflet.esri)
leaflet() %>% setView(lng = 55.0876632, lat = 25.0755935, zoom = 10) %>%
addEsriTiledMapLayer(
url = "https://smart.gis.gov.ae/dmgis104/rest/services/Misc/Env_Imagery/MapServer")
Update: Note that no username or password is required.
I've confirmed that url works by adding it as an ArcGIS server in ArcCatalog, but when I try to run the above in R I just get a blank leaflet map.
How do I specify which layer from the above url to load? There are a number of layers available at that url, such as "Misc/IMAGE2018" and I would like to load these into leaflet.
I am a bit confused as well because when I inspect the url in ArcCatlog it shortens it to "Server URL: https://smart.gis.gov.ae/dmgis104/services" instead of the above, but I am not sure if that matters. See screen shot below as example of ArcCatlog.
Thanks in advance
the issue is that your map service doesn't use the typical web mercator projection and tiling scheme.
you can find an example which includes extra code to explicitly define a custom projection here: http://esri.github.io/esri-leaflet/examples/non-mercator-projection.html

How to generate a graph file?

Is there a way to generate valid graph files like simple-leuven.dot or graphs of other cities available on Rinsim?
We'd like to find a fast way to generate directed cyclic graphs with various geometries.
The Leuven map was downloaded from OpenStreetMap as an XML file and then converted to dot using a script. The code that was used for this has been removed from the main RinSim branch as it is very fragile. You can still find the code in the repository though, see OSM.java in v2.3.3.
A few other city maps have been created using this code and they can be found on this website.
Apparently, the code in OSM.java has been refactored into a project in this github repo osm-to-dot-converter. All you have to do is to create a main method to convert an XML openstreetmap file (.osm). For instance:
public static void main(String[] args) {
OsmConverter myOsmConverter = new OsmConverter();
myOsmConverter.setOutputDir("/home/username/");
myOsmConverter.withOutputName("cityname.dot");
// I am not sure what pruning is used for,
// you can comment out the next line if you do not understand what it is used for
myOsmConverter.withPruner(new RoundAboutPruner(1), new CenterPruner());
// the XML file is to be feed here
myOsmConverter.convert("/home/username/cityname.osm");
}

Can't display Leaflet HTML through R-Shiny (404 error). How to integrate KML file with rMaps or leaflet-shiny?

I'm having some issues displaying an interactive map in R-Shiny that incorporates a KML file. I installed leaflet-plugins and was able to create an HTML file that displays properly by itself in the browser but not within Shiny. This attempt followed an example here - the code is available if you view source.
Because this initial version does not require the HTML itself to change, I attempted to follow the samples here to include the raw HTML in my page but I receive a 404 error with these as well as when I attempted to include it as an iframe within R-Shiny (following this discussion). I then set up an external facing server for both the KML file and the HTML file and got the same result.
I was able to get a map working without the KML file with leaflet-shiny but I'm frankly not sure how to add the KML file and don't see this in the documentation.
Finally, I tried rMaps which does have a "addKML" method, but I can't get it working with various locations of files on my server (
map1 = Leaflet$new()
map1$setView(c(45.5236, -122.675), 13)
map1$tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")
map1$addKML('http://kml-samples.googlecode.com/svn/trunk/kml/Placemark/placemark.kml')
map1
It works without the $addKML line. It might be worth noting that the tilelayer line on example 1 here also resulted in a blank map.
I actually have some possibly similar issues hosting derived title layers that are still unresolved which is one reason I opted for uses KML layers for this demo version of the application, which is why I tagged networking on here as well. I'm using Digital Ocean.
Thank you for any thoughts or pointers you may have.
I think there may be a small issue in the rMaps library. If you inspect the config.yml file
https://github.com/ramnathv/rCharts/blob/master/inst/libraries/leaflet/config.yml you will see that for
content delevery network (cdn) there is reference to
"http://harrywood.co.uk/maps/examples/leaflet/leaflet-plugins/layer/vector/KML.js". This KML reader is a plugin for leaflet from https://github.com/shramov/leaflet-plugins/blob/master/layer/vector/KML.js. When content is delivered locally:
css: [external/leaflet.css, external/leaflet-rCharts.css, external/legend.css]
jshead:
- external/leaflet.js
- external/leaflet-providers.js
- external/Control.FullScreen.js
there is no reference to this javascript file. We can fix this:
require(yaml)
leafletLib <- file.path(find.package("rMaps"), "libraries", "leaflet")
rMapsConfig <- yaml.load_file(file.path(leafletLib, "config.yml"))
# add a kml library
kmlLib <- readLines("http://harrywood.co.uk/maps/examples/leaflet/leaflet-plugins/layer/vector/KML.js")
write(kmlLib, file.path(leafletLib, "external", "leaflet-kml.js"))
# add the library to config.yml
rMapsConfig$leaflet$jshead <- union(rMapsConfig$leaflet$jshead , "external/leaflet-kml.js")
write(as.yaml(rMapsConfig), file.path(leafletLib, "config.yml"))
Now the config.yml will contain the necessary link to the KML reader and there is a local copy stored now in external/leaflet-kml.js. Our example still wont work however as we will get a Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://kml-samples.googlecode.com/svn/trunk/kml/Placemark/placemark.kml. This can be fixed by moving the resource to the same domain or enabling CORS.
We will need to have this file served locally. We can place it as a temporary measure in the leaflet folder in the rMaps package. When a map is created this folder gets copied to a temporary file:
require(rMaps)
map1 = Leaflet$new()
map1$setView(c(45.5236, -122.675), 13)
map1$tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")
map1$addKML('leaflet/placemark.kml')
# temp copy http://kml-samples.googlecode.com/svn/trunk/kml/Placemark/placemark.kml
# to rMaps
sampleKml <- readLines('http://kml-samples.googlecode.com/svn/trunk/kml/Placemark/placemark.kml')
write(sampleKml, file.path(leafletLib, 'placemark.kml'))
# finally try the map
map1
# remove the temp file
file.remove(file.path(leafletLib, 'placemark.kml'))
UPDATE:
There is an addAssets method in rCharts which allows you to add .js files. This allows us to simpilfy things and doesnt require us to write a copy of the js file nor edit the config.yml file.
require(rMaps)
map1 = Leaflet$new()
map1$setView(c(45.5236, -122.675), 13)
map1$tileLayer("http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png")
map1$addAssets(css = NULL, jshead = 'http://harrywood.co.uk/maps/examples/leaflet/leaflet-plugins/layer/vector/KML.js')
map1$addKML('leaflet/placemark.kml')
leafletLib <- file.path(find.package("rMaps"), "libraries", "leaflet")
sampleKml <- readLines('http://kml-samples.googlecode.com/svn/trunk/kml/Placemark/placemark.kml')
write(sampleKml, file.path(leafletLib, 'placemark.kml'))
# finally try the map
map1
# remove the temp file
file.remove(file.path(leafletLib, 'placemark.kml'))

convert .shp file to map with jvectormap-1.2.2

I follow this document and this question.
I have downloaded ne_10m_admin_1_states_provinces files but I can not find
country_code_index (for Iran Or other country) in it.
I use this command in ubuntu command line :
ogrinfo ne_10m_admin_1_states_provinces.dbf -al > Out.txt
out.txt's content is :
How to find --country_code_index AND --country_name_index ?
Go through Map-converter-notes which has very good information about all the steps required to generate a new map from public data.
Linux users can install a very handy tool SAGA-GIS to generate required shape file and then use converter.py to generate map to use with jvectormap.com plugin.
country_code_index is the index of attribute which will be used as code name for specific region on map and country_name_index is the attribute which will be shown as label of region on map. Attributes chosen for these should have unique values in map data table.

Resources