QGIS: latitude coordinates are reversed; map upside down - latitude-longitude

I have been using QGIS to display a map of the long term precipitation average of the Netherlands. However, when QGIS opens the data, the map is shown upside down
I noticed that the coordinates are displayed from 0 - 266 (lon) and -315 - 0 (lat). I figured that the latitude is projected upside down
In stead of -315 - 0 it should be 0 - 315 and the map should look fine. But I can't figure out how to inverse this value.
The file is a NetCdf file. I openend the XML metadata QGIS made for me with EmEditor, but it did show the right coordinates (in lat/lon), So I think it has something to do with the way QGIS sets up the map or the way it converses the lat/lon to meters.
Anybody who encountered the same problem as me? Thank you in advance!

I'm pretty sure you can use the GDAL configuration option GDAL_NETCDF_BOTTOMUP=[YES/NO] to convert from NetCDF to a geotiff, and get the resulting raster correctly oriented north-up. Try using gdal_translate with the above option. See here for some more details.

Thanks to Micha (see the comments):
I was told to solve the problem using GDAL (Geospatial Data Abstraction Library), a method to look into and translate/process metadata. This was quitte hard to understand, while I am relatively new in programming and using powerfull 'languages' like GDAL.
To enter GDAL codes I used the OSGeo4W Shell, which comes with QGIS. The command that I used to flip my map was:
gdal_translate -of netCDF -co WRITE_BOTTOMUP=NO my netcdf.nc output.nc
(see also this short GDAL/netCDF introduction).

In R you can use rotate function
library(raster)
library(gdalUtils)
workdir <- "Your workind dir"
setwd(workdir)
ncfname <- "adaptor.mars.internal-1563580591.3629887-31353-13-1b665d79-17ad-44a4-90ec-12c7e371994d.nc"
# get the variables you want
dname <- c("v10","u10")
# open using raster
datasetName <-dname[1]
r <- raster(ncfname, varname = datasetName)
r2 <- rotate(r)
writeRaster(r2,"wind.tif",driver = "TIFF")

Related

gdal_translate NetCDF to GeoTiff file conversion not working

I am new to geospatial analytics and using NetCDF and GeoTIFF files. I am trying to convert the NetCDF file into GeoTIFF file. I came across this reference: netcdf-to-geotiff-file-conversion. I have successfully installed and can run gdal_translate in my MacOS terminal. However, I get this message I am trying to understand what this means and what I am missing? This appears to be warning, however it didn't generate any output.
My code executed:
gdal_translate some_nc_file_name.nc output.tif
Error/Message:
Warning 1: No UNIDATA NC_GLOBAL:Conventions attribute
Input file contains subdatasets. Please, select one of them for reading.
Here is my data output I previewed in Python:
You appear to have multiple variables in the file, so need to select one. Example (following https://nsidc.org/support/how/how-convert-golive-netcdf-variables-geotiff).
gdal_translate NETCDF:"Input_FileName.nc":variable_name Output_FileName.tif
Based on the warning message, the netCDF file lacks certain important attributes, so some issues may exist with the coordinates etc. in the tif.

Train Tesseract to label icons

I'm trying to create training data for Tesseract 4.0 to identify icons (like, comment, share, save) in screenshots. This is a sample screenshot:
I would like to fine tune the Tesseract to achieve output as below:
Like 147
Comment 29
Saved 5
Actions
58
Actions
Profile Visits 24
Follows 2
I have followed step-by-step as stated in https://pretius.com/how-to-prepare-training-files-for-tesseract-ocr-and-improve-characters-recognition/
I modified the box file as below:
- Heart : Like
- Speech bubble: Comment
- Bookmark: Saved
- Arrow: Share
But, the final training data failed to read the icon as I wanted. Example of error I've got is 'Like is not in unicharset'. Do I have to do something different when creating the unicharset for icons?
I've figured it out. The box editor expects single letter/number instead of full words. I have used Unicode character to interpret my icons. The steps are as below:
Crop all target icons that you wish for Tesseract to detect and save it in one file named as (in my case) own.std.exp0.png
Create box file using the command 'tesseract own.std.exp0.png own.std.exp0 makebox'
Open jTessBoxEditor and input unicode at the char column. The list of supported unicode can be found under program Character Map (https://sites.psu.edu/symbolcodes/windows/charmap/). Example: For heart symbol I used U+2665. Note that some unicode are not supported. It shows as blank square. So, keep trying till you find one that works. My final edited box file looks like this.
Create the final training file which will be own.trainneddata (can be done as shown here https://medium.com/apegroup-texts/training-tesseract-for-labels-receipts-and-such-690f452e8f79 or train using jTessBoxEditor).
Copy the own.traineddata to the directory Tesseract/tessdata and run Tesseract using lang='own+eng'. I used pytesseract and the output is as below:

Ansys multiphysics: blank output file

I have a model of a heating process on Ansys Multiphysics, V11.
After running the simulation, I have a script to plot a temperature profile:
!---------------- POST PROCESSING -----------------------
/post1 ! tdatabase postprocessor
!---define profile temperature
path,s_temp1,2,,100 ! define a path
ppath,1,,dop/2,0,0 ! create a path point
ppath,2,,dop/2,1.5,0 ! create a path point
PDEF,surf_t1,TEMP, ,noav ! print a path
plpath,surf_t1 ! plot a path
What I now need, is to save the resulting path in a text file. I have already looked online for a solution, and found the following code to do it, which I appended after the lines above:
/OUTPUT,filename,extension
PRPATH,surf_t1
/OUTPUT
Ansys generates the file filename.extension but it is empty. I tried to place the OUTPUT command in a few locations in the script, but without any success.
I suspect I need to define something else, but I have no idea where to look, as Ansys documentation online is terribly chaotic, and all internet pages I've opened before writing this question are not better.
A final note: Ansys V11 is an old version of the software, but I don't want to upgrade it and fit the old model to the new software.
For the output of the simulation (which includes all calculation steps, and sub-steps description and node-by-node results) the output must be declared in the beginning of the code, and not in the postprocessing phase.
Declaring
/OUTPUT,filename,extension
in the preamble of the main script makes such that the output is stored in the right location, with the desired extension. At the end of the scripts, you must then declare
/OUTPUT
to reset the output file location for ANSYS.
The output to the PATH call made in the postprocessing script is however not printed in the file.
It is convenient to use
*CFOPEN,file,ext
*VWRITE,Vector(1,1).Vector(1,2)
(2F12.6)
*CFCLOSE
where Vector(1,1) is a two column array created by *DIM, and stores your data to output to file
As this is a special command, run it from file i.e. macro_output.mac

Display variables using CBC MPS input in NEOS

Am trying to use NEOS to solve a linear program using MPS input.
The MPS file is fine, but apparently you need a "paramaters file" as well to tell the solver what to do (min/max etc.). However I can't find any information on this online anywhere.
So far I have got NEOS to solve a maximization problem and display the objective function. However I cannot get it to display the variables.
Does anyone know what code I should add to the paramters file to tell NEOS/CBC to display the resulting variables?
The parameter file consists of a list of Cbc (standalone) commands in a file (one per line). The format of the commands is (quoting the documentation):
One command per line (and no -)
abcd? gives list of possibilities, if only one + explanation
abcd?? adds explanation, if only one fuller help(LATER)
abcd without value (where expected) gives current value
abcd value or abcd = value sets value
The commands are the following:
? dualT(olerance) primalT(olerance) inf(easibilityWeight)
integerT(olerance) inc(rement) allow(ableGap) ratio(Gap)
fix(OnDj) tighten(Factor) log(Level) slog(Level)
maxN(odes) strong(Branching) direction error(sAllowed)
gomory(Cuts) probing(Cuts) knapsack(Cuts) oddhole(Cuts)
clique(Cuts) round(ingHeuristic) cost(Strategy) keepN(ames)
scaling directory solver import
export save(Model) restore(Model) presolve
initialS(olve) branch(AndBound) sol(ution) max(imize)
min(imize) time(Limit) exit stop
quit - stdin unitTest
miplib ver(sion)
To see the solution values, you should include the line sol - after the min or max line of your parameter file.
If this doesn't work you can submit the problem to NEOS in AMPL format via this page. In addition to model and data files, it accepts a commands file where you can use statements to solve the problem and display the solution, for example:
solve;
display _varname, _var;
This post describes how to convert MPS to AMPL.

Which is the best SVG to NSBezierPath library/class?

I am looking for the best SVG to NSBezierPath parser, it's ok if the class/library only takes a string of SVG commands, here is an example:
M 435.722 403.542 h -232.44 v -293 h 232.44 c 0 0 0 35.108 0 81.019 c 0.049 2.551 0.079 5.135 0.154 7.748 c -0.208 15.567 12.1 13.618 19.624 28.192 c 2.584 5.005 5.875 30.5 4.875 34.5 c -7 19 -28.707 22.875 -24.653 44.854 c 0 2.667 0 5.31 0 7.923 C 435.722 364.425 435.722 403.542 435.722 403.542 z
The class/library doesn't neccessarily have to parse the .svg file itself, but it should be able to handle all SVG commands and support relative as well as absolute coordinates (in other words, it should be fully compatible with the SVG 1.1 specs found here).
I have found some classes on the web, but they were all limited and failed with my svg commands above. Which is the best SVG to NSBezierPath parser around these days?
Write a program to parse the SVG file using an XML parser.
This will give you your array of paths which you can feed one by one into the following code:
https://www.touchnoc.com/one_way_ticket_from_svg_to_nsbezierpath
** Make sure to look for the code for iOS on the above page.
However, the above code only works for absolute path coordinates not relative path coordinates. Adobe Illustrator outputs only relative path coordinates. You can open your svg from illustrator in a program called sketch (http://www.bohemiancoding.com/sketch/) and export the svg will give you your file in absolute path coordinates.
Your paths are failing probably because they are using relative coordinates - small c, where most of the scripts I found can convert absolute, or big C.
And, there you go. The whole process is not easy but it is doable! I am speaking from experience.
I don't think something like that is available.
But you should be able to parse that yourself very easily, since the commands map directly to NSBezierPath methods.
It's also helpful that the command comes first, so you could do the following:
split into array by spaces
take first element and map to command
take next x elements as parameters (x is known depending on command)
call the matching method on NSBezierPath
If the string is very long, you can also do the same by parsing it stream-wise.