I have some meteorological data wich are exported to netCDF format and I want to display them in Google Maps.
I tried the Panoply software, mainly following these http://marinedataliteracy.org/ops/pano_gridsvecs.htm instructions and succesfully exported the data into .kml files.
The kml file displays fine in Google Earth, but when loading it in Google Maps nothing is being displayed.
The JavaScript code that is loading the kml is definitely correct, because other types of kml are displayed correctly. Just in case, this is the code:
var kmzLayer = new google.maps.KmlLayer("LINK_TO_KML");
kmzLayer.setMap(map);
There is also a project called netcdf2gmaps here http://code.google.com/p/netcdf2gmaps/ but it seems abandoned and there is no feedback for it.
So is there any way to display the netCDF data to Google Maps?
I don't know if you solved your problem, but for reference to question title I thought to add more info.
Panoply (or IDV) export to KMZ (zipped KML) in a manner of simple PNG snapshot of their current display and lon/lat boundaries, like this:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<GroundOverlay>
<name>Maximum_temperature_Maximum_unwe in GEFS_Global_1p0deg_Ensemble_deri</name>
<Icon>
<href>Maximum_temperature_Maximum_unwe in GEFS_Global_1p0deg_Ensemble_deri.png</href>
</Icon>
<LatLonBox>
<west>-29.1622</west>
<north>55.0</north>
<east>49.1622</east>
<south>25.0</south>
</LatLonBox>
</GroundOverlay>
</kml>
And that seems like only way to Google Earth interface - bitmap images. Which is a sad fact that Google Earth is not designed for visualization or numerical model data, as it can't represent varaious other features.
If overlaying bitmap in Google Earth/Maps is the task than as you have already noticed it's just a matter of double clicking produced KMZ file:
or for Google Maps, uploading the file and pasting the path in Google Maps search bar:
Related
I have been given the task of making a KML file that can be dropped onto Google Earth or Google Maps and display the data as a heatmap. The script has to be written in PHP and generate a KML (xml) output. I have made some circles and such work but I am coming to what I think is a realisation that it can't be done after hours trying to work this out. Does anyone know if you can generate a .kml file that you can drag and drop onto google earth for example and it will display like a heatmap, similar to the below.
I can not use any JavaScript (or I wouldn't have this problem in the first place).
Example single point KML file.
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.2">
<Placemark>
<name>Test Point</name>
<description>Test Point Description</description>
<Point>
<coordinates>147.095947265625,-23.664650731631614,0</coordinates>
</Point>
</Placemark>
</kml>
I created two KML files by copying and pasting their content directly from Google Manual. One file it the first example (using CDATA), another one is the second (without CDATA). I then created a new custom Google Map and added two layers importing both KML files.
The problem is that I cannot make formatting work. There are no red, italic, or bold fonts on the description as they should be according to both KML files.
That is how I can see the description in both Chrome and IE, on two different computers (Windows 10 64 and Windows 7 64):
Any ideas why I cannot see formats and how to make them work?
I think Google Earth supports HTML tags, but Google custom map (old name : my map) does not support HTML tags currently. KML file is just a data file. Supporting all features of KML format, or not is depends on the application.
I have some dynamically generated KML files that I'd like to display on Google Maps. That's the easy part, I've done it a few times before, no problem.
What I want is for the KML files to only be cached by Google for a request. That is to say, if a person visits a page with a Google Maps embed, which has my KML loaded and displayed, I want that KML file to be used for that page load. But if the user were to refresh the page (having the same Google maps URL), I would like the KML file to be re-fetched.
The simple "just add a timestamp argument" doesn't work, as I'm not going to be in control of the urls passed to Google Maps on the page (just most of the url).
Looking at the <Link> and <networkLink> tags, they seem to let you control expiration, caching, refresh, etc., on an external resource. Reading the documentation, it would seem that using <refreshMode>onChange<refreshMode> to use a two-layered approach will get me what I want.
After testing this, Google isn't actually refreshing the content of the linked KML file, even after 10-20 minutes and multiple maps reloads (when I provide the same url to the Maps search box).
These are the KML files that I am using:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<NetworkLink>
<Link>
<href>URL</href>
<refreshMode>onChange</refreshMode>
</Link>
</NetworkLink>
</Document>
</kml>
...
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
<Placemark>
<name>NAME</name>
<visibility>1</visibility>
<Style>
STYLE
</Style>
GEOMETRY
</Placemark>
</Document>
</kml>
... With URL, NAME, STYLE, and GEOMETRY replaced with correct content. Does anyone have an idea of what I might be doing wrong? Or if what I want is possible?
This is what I know:
onChange will cache the response completely unless you enable viewport passthrough on the KML loading via <viewFormat>, I've not seen any refresh after several hours.
onExpire with the use of a 'max-age' header on the linked KML file does not work in Google Maps (as per documentation), though I saw behavior described in [1], which could be related to a default internal Google Maps expire time.
onExpire with the use of <NetworkLinkControl> and <expires> sort-of works, in that the data seems to expire after the provided expiration time, though the behavior looked to be closer to [1]
onInterval will refresh the data, assuming your <viewRefreshTime> is sufficiently large, and will do it on its own schedule (the timing isn't reliable in the slightest) but the map view starts zoomed out completely (there doesn't seem to be a way to fix this).
[1] If you specify a 'max-age' of X seconds and you leave the page open, the KML will never refresh while the page has focus. If you move the focus to a different web page or application, then wait until some time well after the page should have refreshed (sometimes waiting 2 minutes is enough, sometimes it's not), and you go back to the page, it may make up to 30 requests in rapid succession to try to refresh the data if you don't return content, or just once if you do return content.
Long story short: cache control of KML files inside Google Maps with onExpire and onInterval is not reliable at all. At some point after your data is loaded, it will be refreshed, because Google's cache has gotten rid of it. But when does that cache expire? Some random time that is at least 5 minutes out.
For expiration, Google follows the expiration time in the headers, but enforces a minimum expiration of 5 minutes to prevent 3rd party servers from getting hit with effective denial of services attacks.
I'm want to display my blog as a Google Map overlay (each post contains geotags). How can I dynamically create a KML overlay from an RSS? Or better, how can I create a loop (PHP) that would display map placemarks according to given geotags?
Thank you!
Converting from one XML format to another XML format? Sounds like a job for XSLT!
Then again, I’ve just noticed that the Google Maps API seems to accept RSS as well: http://googlemapsapi.blogspot.com/2007/03/kml-and-georss-support-added-to-google.html
I'm trying to set up a KMZ file for use in Google Earth where the balloon contents are mostly defined in HTML files, which are embedded using iframes. The setup works with a plain KML file and the extra HTML files when using relative links on the local filesystem (assuming filesystem access is enabled).
My problem is that I can't find a way to create a KMZ file containing all files in an interlinked fashion. The KML specification doesn't talk about the issue at all (in fact KMZ appears only a few times in the whole document). I couldn't find any other documentation on KMZ either.
Is it possible to link to other HTML files within a KMZ? If yes: how?
Yes the Kml specification allows this, you just use relative paths.
However your issue is really to do with the security restrictions in specific applications on certain types of content.
For example the full Google Earth Client allows you to load Flash (swf) content in to Balloons whilst the Goggle Earth Plug-in does not. The same goes for iFramed content, etc.
So the answer to question would totally depend on which application are you viewing the Kml/kmz in and has nothing to do with Kml or Kmz specification.
Realize that there is the OGC KML Standard and how the specification of that standard gets interpreted and implemented in the Google Earth software. In particular there are some grey areas not well-defined in the spec that Google Earth implements as it does. The rules governing KMZ files and embedded content is not well defined and are clearly implementation specific. Some of the details are defined in Google KML Reference documentation and some are not. Some inconsistencies and undocumented features of KML and Google Earth can be found in the KML Errata.
There are restrictions both for what media content (embedded inside KMZ file) can be displayed inline within a description balloon and as well as what content can be linked to and accessed.
Here are some restrictions for <iframe> content listed in the KMZ Tutorial
The <src> element within an <iframe> element cannot point to a local
file on disk, nor can it point to a file inside a KMZ file; it must
point to a URL on the Internet that a browser can visit.
As an exception to this rule you can in fact have an HTML file within a KMZ file and include that as <src> element within an <iframe> in the feature description with a relative URL but not many other media types are supported.
If you enable the "Allow access to local files and personal data" option in Tools/Option/General menu panel then this relaxes some access rules and are able to access some links to content (e.g. HTML, PDF, etc.) as you would from a web browser but mostly local files external to the KMZ file.