I want to display the kml file in cesium globe, and as described in the cesium's workshop code, we need to load the file by passing it with the file location (or URL). The following line of code is the specific line of code that cesium loads the kml.
var geocachePromise = Cesium.KmlDataSource.load('./Source/SampleData/sampleGeocacheLocations.kml', kmlOptions);
The entire code is available here
My question is: I have the longitude, and latitude, (and height) information saved in variables and instead of always saving them into .kml file and then load them via folder, I want to pass this information to cesium kmlDataSource (the code above) directly.
It would be great if anyone has any solution to this.
Please let me know if further information or code snapshot is required. Thanks
If you already have the information you need stored in JavaScript variables, there's no need to export to KML and import it back into Cesium. You can directly add the indicators you need as Cesium Entities, which is what the KML loader is creating when it reads a KML.
Typically, a KML-like pin is represented by a Cesium Entity containing either a point or a billboard, and optionally an associated label.
Here are some relevant demos that show how this is done:
Billboard demo
Map Pin demo
Label demo
Each of these demos calls viewer.entities.add({ ... }) along with a position for the Entity and some sort of graphical indication(s) to display to the user. You may place one of each on an Entity, for example a billboard and a label are often both defined when adding a typical KML-like Entity.
If your data is stored on the server however, you will need some mechanism to stream it to the browser. CZML is Cesium's native format for doing so, but KML is also available as an alternative for certain kinds of graphics. You may also use any API of your own design, and create Entities when the data becomes available in JavaScript.
Related
I'm using folium.GeoJson to plot polygons on a map. I have one dataset with different fields/attributes; I'm using the same data for each folium.GeoJson layer but with various fields to display different attributes and add them in layer control. I guess this makes the final Html file big in size.
One solution I found to reduce the Html file is to minify it, but the slimmer package isn't available in anaconda.
Do you have any suggestions for this case?
You can reduce the size of the HTML file dramatically by using mapshaper to reduce the size of the geojson file.
Drop your file or search and import. I check the box "detect line intersections" and upload:
Choose your method of simplifying the coordinates (I use Douglas-Peucker method, and prevent shape removal):
Then set the simplification (you can play with the settings to get the desired result, I found 3% worked well)
Then export the file (it exports as a .json file so remember to change to .geojson:
This reduced the file from 17.6MB to 614KB and the outputted HTML file from 222MB to 7.58MB
Found a way: to simplify spatial data that significantly reduces data size.
In my case, I was using shapefile as the spatial data, particularly polygons, that is, the collection of points (vertices) and highly affected the data size. I just used the simplification tool that removes extraneous vertices but preserves essential shape. I used the Simplify Polygon tool in ArcMap, but the same is possible in python with the geopandas.GeoSeries.simplify function and in R with the 'sf' library.
Mapping a Cloud Optimized Geotiff raster layer in Mapbox GL JS
I think I use a raster source, the source data need to be tiled. the URL would be like .../{z}/{x}/{y}.tif.
But I don't know how to make above URL. how to make url??
I'm not exactly sure what you're asking. If you're asking "how do I turn this GeoTIFF into a tiled raster source", two options are:
Upload it to Mapbox. (In theory this works, although it has not always been successful for me.)
Use GDAL to convert it to mbtiles, then host the .mbtiles file somewhere (either on Mapbox, CloudTiler, or your own hosting.)
In the latter case, that would look like:
gdal_translate myfile.tif mytiles.mbtiles
Mapbox SDK wants to fetch tiles by Z/X/Y. However, you can probably register a NSURLProtocol subclass where you can take the Z/X/Y URL and create the proper COG request, transform the image and return the correct content.
I have used this to register mbtiles:// as a URL scheme and my NSURLProtocol subclass transform the Z/X/Y URL to a SQLite select statement.
You can read more on this subject over at https://github.com/mapbox/mapbox-gl-native/issues/12026
I've been asked to insert an .IFC viewer into a web page already built, to:
explode building visualization into floors
rotate the building
colour spaces based on their temperature
add labels to objects
load .ifc files stored on private servers
Does autodesk viewer meet those requirements? All of them?
Additionaly, is it feasible to change the viewer language through a config file or specific functions?
explode building visualization into floors
The built-in explosion is by model components and not floors and there's option right out of box to specify a granularity level.
Nonetheless you can use viewer.cutplanes (see doc here) to isolate the levels and go from there - see sample here.
rotate the building
This can be done by either THREE.js transformation or Viewer's model load options:
THREE.js: Perform transformation recursively by traversing all children components under the model's root dbid. See this great article here for enlightenment.
Load option - see live sample here:
var options = {
placementTransform:THREE.matrix4,
globalOffset:{x:0,y:0,z:0}
};
viewer.start(svfURL, options)
colour spaces based on their temperature
Use viewer.setThemingColor (see doc here) to apply temperature colors - find the parent dbid of the room or and use the recursive flag to apply color to all its children components. See code sample here.
add labels to objects
See here for details and a few helpful links at the start of the article.
load .ifc files stored on private servers
You can download the translated derivatives (SVF and its resources - obtain a manifest of them from GET :urn/manifest) to your own storage locations and load them by their URL directly. See my live code sample above for details and find the source code for our online extractor tool (http://extract.autodesk.io) here for ideas to download the derivatives.
is it feasible to change the viewer language through a config file or specific functions?
Viewer implements the i18n standards so you can do:
Autodesk.Viewing.i18n.setLng('fr');
Autodesk.Viewing.i18n.localize()
I'm just trying to figure out how to create world file. I saw some explanation but I notice world file having the easting and northing values but not the zone value. So how the location of the map will be identified, or I'm missing something.
Thanking you.
The world file does specify numerical geographical location for an image, but it unfortunately does not contain any information about what coordinate systems is used.
Such information typically comes in a separate file with extension .prj and is defined usually with the WKT standard and via a unique EPSG code of the coordinate system.
To simplify the search for coordinate system definitions we created an online tool:
http://epsg.io/
There you can use simple search phrases and preview position of any coordinates on a map - and also download the .prj file mentioned above.
Because you have tagged your question with "maptiler" I expect you want to cut the map tiles from your geodata and world file with the MapTiler software.
The coordinate systems can be specified directly in MapTiler easily. See http://www.maptiler.com/how-to/coordinate-systems/
I am trying to build a custom map in Tile Mill and am new to programming in general so I apologize is if comes off as uninformed. I've done research but I'm not sure if I'm looking in the right place.
My basic question: this is an embedded map of restaurants in the SF area. Is there a way for me to extract the data for the locations to use in building a custom map of my own?
http://www.sfgate.com/food/top100/2012/map/
It seems that if the location markers exist on a map, that meta data is somewhere, I just don't know how/where to access it....I believe the raw formats for inputting location into a map are CSV or KML and wondering if there is a way to extra these data types from embedded maps.
Thanks!!
View the source of the page in question, look for the data (it's under the variable mapLocs, copy it from the page, and write a little script to convert their format to CSV.
^ this is likely against at least 2 different copyrights (newspaper's & geocoder's), so proceed at your own risk.