Convert Vector to Raster - Projected Coordinate System (X and Y) but NOT Geographic Coordinate System (lat and lon)

Hi
I have polylines in a projected coordinate system (X and Y). I would like to convert these vector data to raster data.
I used 'vec2mtx' but get errors because my projected values are NOT within -90 and 90 or −180 and 180]. My values are around 510000 for X (False_Easting) and 6023150 for Y (False_Northing)
I tried to fix vec2mtx but it did not work.
Is there another function, tool or whatever which I can use? Do you have any idea how to convert vector projected map data to raster data?
Thanks a lot, any suggestion is more than welcome
Cheers
Claudia

8 Comments

What range of input values are needed for X and Y, and how finely grained do you want the raster data to be?
Hi Walter
Thanks for your prompt reply.
The range of input values are
min(X) 1999900 meter
max(X) 2627380 meter
(I put the wrong value in my first post)
min(Y) 5311270 meter
max(Y) 6077600 meter
I can input X and Y in different forms
Form A: <1x317076 double>
Form B: 24706 polylines each in the form <1x18 double> (or smaller or bigger).
I am not sure which density is the best. I have to try different ones. I could start with 1000 grid cells per kilometer (1 grid cell per 10 meters).
Do you recommend different ways for different densities?
Thank you very much
Claudia
At 1 grid cell per 10 meters, that range of X and Y would need a grid of 62748 x 76633 which would require about 4 1/2 gigabytes at one byte per grid cell. That would require very careful management if you are using a 32 bit version of MATLAB (those usually cannot construct an array of more than about 800 megabytes in practice.)
Q: What do you want to have happen when the vectors cross or touch?
Q: Are the vectors to be different colors?
Q: What will you do with the raster data? For example, could you just plot() using vector coordinates and getsnap() the resulting axes image? Though if you do that, you are going to need somewhere on the order of 750 meters per pixel or worse.
Hi Walter
Thank you for your feedback.
Answer 1 and 2:
For the beginning I just need a binary grid.
If one or more lines cross the cell, the cell gets one (black).
If no line cross the grid cell, the cell gets zero (white).
So, black-white is good enough.
Therefore, in my understanding I only need one bit per cell which would be 0.6 GB for the grid of 62748 x 76633. (Thanks, I wouldn't have thought on calculating it without you pointing it out).
Answer 3:
I need the binary data to do some fractal analysis. The first method is 'box counting'.
My first approach was imaging the vector data, exporting it (.jpg), imread the jpg and analysing the grid data.
For testing purposes it worked, but there is a loss of data quality. Still, I lose quality if I convert the vector in raster data but I just try to minimize the loss.
Thank you for your help
MATLAB is not designed to store values by bits; the storing and retrieving has to be done mathematically or by using the bitset() and bitget() calls (which tend to be slow.) The smallest logical data type in MATLAB is "logical", but that is presently implemented at one value per byte (except I think I saw one special case might internally be stored at 8 logical per byte.)
How dense are you expecting the result to be? 25000 lines on a grid that size doesn't sound like much at first thought. If you expect a lot of empty area, then using a sparse array of logical might be suitable.
Box counting... that sounds to me as if it could be done piece-wise? If you were to divide the logical output grid into a number of tiles, and do the drawing one tile at a time, then could that be productive? I suppose you might need an overlap area if the boxes are sliding smoothly.
Do you have an estimate for the longest straight line segment (in meter) ? The shorter the lines are, the more effective preprocessing can be at reducing the cost of constructing fine details for a section.
Hi Walter
Thank you for your help. I am not sure but I have the feeling that this gets more complicated than is should. If the data has been unprojected I could just have used vec2mtx. The problem with vec2mtx is that it always checks if the data is in the form lat and lon (by checking the boundaries i.e. -90 to 90, and -180 to 180, respectively). Furthermore vec2mtx links to other functions which do the same. So, I could try to find all the commands which lead to an error because of projected data. But as I am new to MATLAB I thought there should be an easier way.
My shortest polyline is 1.67 m and my longest polyline is 124457 m. I am not sure how many coordinates the longest polyline has but all polylines together have around 317076 pairs of X and Y values.
Thanks you and cheers,
Claudia
Why not divide the data by 10^5 to get it into the range accepted by vec2mtx ?
Hi Walter
Good idea - and quite obvious - wonder I did not think on it :-)
Just tried it. But still it does not work ...
I tried vec2mtx with an example data and it ran. I could not find any difference between the example data and my data. Will check the functions and the data again ... hopefully I find sth.
However, thank you very much for your help.
Claudia

Sign in to comment.

Answers (0)

Products

Asked:

on 9 May 2012

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!