How to create terrain files with points in Cesium? - cesiumjs

I have a DEM file with XYZ points (file sample image), and I want to use it to create terrain in Cesium with it. I tried to translate it to GeoTiff by ArcMap, but it is not supported by cesium terrain builder.
How could I create terrain files with points in Cesium?

Cesium is able to consume Quantized Mesh tiles but not GTIFF or XYZ directly.
First, you will have to convert your XYZ file to e.g. GTIFF and transform it to WGS84 coordinate reference system. Both can be done using gdal.
Second, convert your transformed GTIFF files to quantized-mesh format.
I created a Docker image for that purpose. Check out the Github page of tumgis/cesium-terrain-builder-docker for a detailed documentation of the entire process.
Finally, you will need a service like CesiumTerrainServer to serve the tiles to a Cesium application.

Related

QGIS: all my points end up in the Atlantic Ocean

I'm following the tutorial guides in QGIS webpage, but I can't correctly import the dataset from the .csv file in the guide.
Here you can download the .csv file
Here you can download the shape .shp file
I imported the shp just by double clicking on it inside of QGIS
I pressed ctrl+L to open the delimited text layer window
from there i selected the .csv file using x as longitude and y as latitude
Here the result
Wrong point localization
What I did
The latitude and longitute coordinates look correct in the .csv file
I copied a location coordinates from the world map (ireland in my case) and I created a test .csv file with those coordinates. When import the csv file in my project it is placed in the atlantic Ocean and not in Ireland.
Is this a bug? I really can't understand what is happening.
As you can see the points are relatively well distributed, that means the original information is correct but there is something that has to do with the scale of the points that does not work (even tho coordinates are not ambiguous)
You will need to know a few things.
1.If the files you are using have coordinates systems assigned to them.
I am unsure about shp files as i deal mainly in Mesh Datasets and Rasters.
I do know that the CSV coordinates or Text file coordinates if they are GPS values ie:Lat Long have to be saved into a co-ordinates system value and that the QGIS project has to use the same coordinate system. The system uses the GPS coordinates to place the points accurately on the QGIS map. My Method is to use a site like bbox and use my Coordinates system of choice and record these Lat Long values into .CSV and then copy the same CRS settings from bbox within QGIS project then the shp and or imported files end up placed correctly when you load the imported text file layer or shp file. Also file formatting is important for text files like you have ie:CSV. If you set the CRS within the QGIS project if the layer you import in is from another CRS QGIS will automatically change this to the CRS you have set. If you do not have geographic information setout correctly you will have the problem you have now also another problem is if the file does not contain CRS information at all.
But from what you are telling us this looks like a CRS mismatch problem.
2.What the coordinates system is for the files you have ie:epsg 4326 or 3857 these are two very different different systems that can drastically alter the placement of your points.
3.If they dont have a coordinate system assigned to them then you will need to assign one and use this same coordinates system within QGIS project before you import in the files. .
4.If the files do contain coordinate systems references then in QGIS you will need to set the project CRS system to the same as the files you have. This will apply the CRS to all layers you add to this project weather they are vectors, mesh, rasters and or base layers.
Good luck.

How to use AWS S3 raster file in Mapbox gl js?

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

How to load longitude and latitude information into cesium kmlDataSource?

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.

how to create a vector map of some locations

I want to mark some locations in a vector map. And would like to save the map in pdf format with separate layers.I tried arcgis but the map is online cannot export it to a file. can i know what is the common and standerd way of representing data using a vecotr map
Try this vector maps first, they have free versions, it can be useful:[http://vectormap.info/free-maps-for-all-designers-and-mappers][1] it could be easier for you too

Best way to overlay an ESRI shapefile on google maps?

What is the best way to overlay a shapefile in Google Maps?
After some reading suggests that, converting shapefile into KML and overlaying KML in Google map is an option. If that is the case, how do I convert a shapefile into KMLs?
I believe there would be a few open source tools available for this conversion. Can anyone point to a tool to covert a shapefile to KML without any loss of data?
I like using (open source and gui friendly) Quantum GIS to convert the shapefile to kml.
Google Maps API supports only a subset of the KML standard. One limitation is file size.
To reduce your file size, you can Quantum GIS's "simplify geometries" function. This "smooths" polygons.
Then you can select your layer and do a "save as kml" on it.
If you need to process a bunch of files, the process can be batched with Quantum GIS's ogr2ogr command from osgeo4w shell.
Finally, I recommend zipping your kml (with your favorite compression program) for reduced file size and saving it as kmz.
as of 12.03.2019 FusionTables is no more...
Import the Shapefile into Google FusionTables ( http://www.google.com/fusiontables ) using http://www.shpescape.com/ and from there you can use the data in a number of ways, eg. display it using GoogleMaps.
I would not use KML. Instead, use GeoJSON which you can natively consume in Google Maps API now. It is a newer feature that didn't exist from the original responses.
In any case, simply open the SHP file in Quantum GIS, and then you can output it in any format you like (KML, GeoJSON).
If you are using Google Maps for Work, I found a premium extension that handles loading shapefiles directly where you can just connect direct to the shapefile that you generate from ESRI. I did a search on the CMaps site and found this snippet which loaded US by state shapefile: https://gmapsplugin.net/cmapsanalytics/assets/shapes/usstates.shp
var cMap = new centigon.locationIntelligence.MapView();
cMap.key([your_api_key]);
cMap.layerNames(["Basic Shapes"]);
cMap.dbfKeys([['Alabama','Alaska','Arizona','Arkansas','California','Colorado','Connecticut','Delaware','District of Columbia','Florida','Georgia','Hawaii','Idaho','Illinois','Indiana','Iowa','Kansas','Kentucky','Louisiana','Maine','Maryland','Massachusetts','Michigan','Minnesota','Mississippi','Missouri','Montana','Nebraska','Nevada','New Hampshire','New Jersey','New Mexico','New York','North Carolina','North Dakota','Ohio','Oklahoma','Oregon','Pennsylvania','Rhode Island','South Carolina','South Dakota','Tennessee','Texas','Utah','Vermont','Virginia','Washington','West Virginia','Wisconsin','Wyoming']]);
cMap.userShapeKeys([['Massachusetts','Minnesota','Montana','North Dakota','Hawaii','Idaho','Washington','Arizona','California','Colorado','Nevada','New Mexico','Oregon','Utah','Wyoming','Arkansas','Iowa','Kansas','Missouri','Nebraska','Oklahoma','South Dakota','Louisiana','Texas','Connecticut','New Hampshire','Rhode Island','Vermont','Alabama','Florida','Georgia','Mississippi','South Carolina','Illinois','Indiana','Kentucky','North Carolina','Ohio','Tennessee','Virginia','Wisconsin','West Virginia','Delaware','District of Columbia','Maryland','New Jersey','New York','Pennsylvania','Maine','Michigan','Alaska']]);
cMap.labels([['Massachusetts','Minnesota','Montana','North Dakota','Hawaii','Idaho','Washington','Arizona','California','Colorado','Nevada','New Mexico','Oregon','Utah','Wyoming','Arkansas','Iowa','Kansas','Missouri','Nebraska','Oklahoma','South Dakota','Louisiana','Texas','Connecticut','New Hampshire','Rhode Island','Vermont','Alabama','Florida','Georgia','Mississippi','South Carolina','Illinois','Indiana','Kentucky','North Carolina','Ohio','Tennessee','Virginia','Wisconsin','West Virginia','Delaware','District of Columbia','Maryland','New Jersey','New York','Pennsylvania','Maine','Michigan','Alaska']]);
cMap.polyDataSources([centigon.locationIntelligence.CMapAnalytics.DATA_PROVIDERS.SHAPE_DATAPROVIDER]);
cMap.layerTypes([centigon.mapping.Layer.TYPE.POLY]);
cMap.locations([["https://gmapsplugin.net/cmapsanalytics/assets/shapes/usstates.shp"]]);
cMap.panTo("USA");
cMap.zoomLevel(3);
Do you mean shapefile as in an Esri shapefile? Either way, you should be able to perform the conversion using ogr2ogr, which is available in the GDAL packages. You need the .shp file and ideally the corresponding .dbf file (which will provide contextual information).
Also, consider using a tool like MapShaper to reduce the complexity of your shapefiles before transforming them into KML; you'll reduce filesize substantially depending on how much detail you need.
Free "Export to KML" script for ArcGIS 9
Here is a list of available methods that someone found.
Also, it seems to me that the most efficient representation of a polygon layer is by using Google Maps API's polyline encoding, which significantly compresses lat-lng data. But getting into that format takes work: use ArcMap to export Shape as lat/lng coordinates, then convert into polylines using Google Maps API.
Just to update these answers, ESRI has included this tool, known as Layer to KML in ArcMap 10.X. Also, a Map to KML tool exists.
Simply import the desired layer (vector or raster) and choose the output location, resolution, etc. Very simple tool.
2018 already... I've found this fantastic online tool http://mapshaper.org/ to convert from ESRI shapefiles to SVG, TopoJSON, GeoJSON.
Here is the explanation of how to use it https://www.statsilk.com/maps/convert-esri-shapefile-map-geojson-format
Fast and straightforward! :)