How to convert a KML into geoJSON within a EE-script? - google-earth-engine

I am struggeling with the logic of EE. I want to export an image (median of NDVI) to my google drive. However, the region for which I want to cut out the image has to be in geoJSON format. Yet, I cannot upload this format to a Fusion Table nor can I convert it within the scripting language of the playground.
I tried already this:
new polygon = myPolygon.togeoJSON()
but it did not work.
if anybody could help ?
here is the link to my playground
https://ee-api.appspot.com/7260e67a9f12397015b971f5bf6a9467
if you try the download in the Task tab you will also find that the download will never stop...any ideas why?
thanks in advance!

I guess you might have already figured it out, with the question being asked more than a year ago.
The task never finishes, because you're trying to download the global NDVI image, not the clipped one ...
Best

Related

How to color some numbers in Excel cell using python or R

I have this example of Excel file where the data contain some random values. I generated this using RAND() function.
What I want to do is read this excel file using R so that I can color red and bold the number 9 wherever it appears in the cell. Is this possible to do?
I've been searching on Google a while but haven't been able to figure it out any other way other than using VBA. But it's not an option.
Does anybody have an example of how to achieve this?
What I wanted to do is not possible using any of the python packages - xlsxwriter can only do rich text like I wanted but only on new cell but cannot modify, openpyxl can do a lot of things but not rich text. Wasn't sure if it could be done using R or not, but seems like it's not possible to do what I want done. I saw a Google Group discussion here where they showed a potential method to perform what I wanted, but that method didn't work for me. It showed .jnew is not recognized.
So, instead, what I did is created a function to add a color dot (image) to the cell to delineate that the cell contains the value I'm searching for - 9 in this case. The reason I can't use conditional formatting is because there's another conditional formatting that is applied for another logic.
def __add_color_dots__(self, ws=None, excel_filename=None):
from openpyxl.drawing.image import Image
import os
path = os.path.abspath('blue-dot.png')
image = Image(path)
image.anchor = 'C4'
ws.add_image(image)
return ws
Hope this will help someone later and that this method maybe a useful workaround.

How to embed a plotly graph on a wordpress website?

I am trying to embed a plotly graph I created in R on a wordpress website. It seems a lot more difficult than it should. Perhaps I am missing something obvious. Here is what I tried:
solution 1: saved the graph as an html using htmlwidgets::saveWidget(as_widget(Basic_Spending_Graph), file = "Basic_Spending_Graph.html"). Then use that html to either embed the whole file or html source code into the website. There are numerous problems with this approach. Firstly if I embed file it embeds a link to the file where you can open the page rather than fully embedding the graph within the page. Secondly the file is 3 Mbs, which over time could put a strain on website speed which is using shared hosting.
solution 2: export plotly graphs from R to chart studio which allows you to host graph on their server and generate an html embedding snippet. This seems like a great solution, but I am struggling to find an easy way to export from R to chart studio, since I already spent quite a lot of time creating the graphs in R. Apparently there is a way to export the charts to chart studio, but nobody seems to explain how?
I may be missing something very obvious considering plotly was designed with web in the mind! Any advice would be greatly appreciated. What is the best way of getting plotly charts on the webpage?
Thanks!
I can't help you with solution 1, but re: solution 2, while this is maddening to find, there is actually a pretty simple solution.
First, you need to register with chart studio online and generate your api key. For whatever reason, to generate your api key you need to view your "settings." (see here: https://chart-studio.plotly.com/settings/api)
Once you've got your api key, you can run the following code from R and it will upload your plotly chart to your profile.
#first we register to upload to plotly
key <- readLines("path/to/your/api/key")
Sys.setenv("plotly_username"="<your username>")
Sys.setenv("plotly_api_key"=key)
#now we post to plolty
plotly_POST(
x = last_plot(),
file = "<whatever you want to name your plot>",
fileopt = "overwrite",
sharing = c("public"),
world_readable=TRUE
)
#note that evidently, plotly_POST is depreciated, though it worked for me as of 11/2020
#use instead the call below, with the same arguments
api_create(
x = last_plot(),
file = "<whatever you want to name your plot>",
fileopt = "overwrite",
sharing = c("public"),
world_readable=TRUE
)

GeoTIFF to HDF Conversion?

I'm in a big trouble. I've downloaded a GeoTIFFF Dataset from http://earthexplorer.usgs.gov/ ; my problem is that I need the dataset in HDFv4 format, because I've to open it in IDL (please don't tell me "IDL can open GeoTIFF", I NEED HDFv4 format) . May you please suggest me a tool that does this conversion?
Thanks a lot.
Just to get you started, you could read in the image and its GEOTIFF tags using the following command:
file = FILEPATH('boulder.tif', SUBDIR=['examples','data'])
data_variable=READ_TIFF(file, GEOTIFF=GeoKeys)
HELP, GeoKeys, /STRUCTURE
You would then need to pull apart the geotiff structure and write the data back to an HDF4 file. I don't quite understand why you need HDF4, and I'm also not sure how you're going to write the GEOTIFF data into the HDF4 file, since HDF4 doesn't have anything "specific" about map projections.
See the docs for more details:
http://www.harrisgeospatial.com/docs/read_tiff.html
Here's a really bad way to do the conversion:
https://www.hdfgroup.org/HDF5-FAQ.html#gtifftohdf
Basically, in that case you are only saving the image data, not the geotiff-specific data.
Good luck!

How to create Store for native binary format(.ID, .DAT, .Tab, .MAP) in geoserver

Hi i have four different file format (.ID, .DAT, .Tab, .MAP) i have to upload these in geoserver and see the map . Are these file format supported by geoserver.if yes please help me how to do it i had done googled and haven't found any solution.
Hi this is a good question As far i know these file formates are not supported by the geoserver so if you want to see map i will suggest you should go for .shp file format

Extracting path data from an SVG map to use in RaphaelJs

I'm trying to build an an interactive map using RaphaelJS (e.g. http://raphaeljs.com/australia.html). Please check the source. It requires map path data to input. There is no clear explanation anywhere about how to obtain this information, other than the fact that illustrator or inkscape are capable of doing it.
I'm looking to obtain "States" path data from this India map: http://en.wikipedia.org/wiki/File:India-locator-map-blank.svg
well, this one is easy. SVG is just a simple XML file. So you don't have to "extract" anything via Illustrator.
Just open the SVG in any text editor and it's all there! (the path data string you can use with RaphaelJS path-function is held in the d-attribute of the path nodes).
Watch our for copyright issues when using SVG files of others ;)
Skunks
You could also use a converter like Ready.Set.Raphael to extract the paths for you and create the javascript output. It's a real time saver!
For older SVG files the path data will need to be optimized for RaphaelJS. Open the file in Inkspace and save as Optimized AVG. If you have an AVG file that opens as a blank image in Adobe Illustrator, edit the file with a text editor and set the first two values of the viewBox to 0,0. Both steps may be required when working with map AVG files from Wikipedia.

Resources