Okay, I got it!

Now I have a script that reads my points from the database and creates a
raster!
But, like usual, I have a question: the geotiff image size is 578x479, at
the moment. The problem is that on a large scale I see only a low-resolution
version of the image (see
http://armisael.silix.org/files/zambia_map_different_zoom.jpg ). It seems
that the pixel size of the geotiff is maintained through the scale factor.
Is it related to the way I create the geotiff?

I'm doing the following:

(x1, x2, y1, y2) = layer.GetExtent()
width = (int) ( (x2-x1) * RESOLUTION )
height = (int) ( (y2-y1) * RESOLUTION )

driver = osgeo.gdal.GetDriverByName( FORMAT )
dst_ds = driver.Create( OUT_NAME, width, height, 1, osgeo.gdal.GDT_Byte )
raster = numpy.zeros( (height, width), dtype=numpy.uint8 )

dst_ds.SetGeoTransform( [ x1, (x2-x1)/width, 0., y1, 0., (y2-y1)/height ] )
srs = osgeo.osr.SpatialReference()


srs.SetWellKnownGeogCS( 'WGS84' )
dst_ds.SetProjection( srs.ExportToWkt() )

Is there something wrong?
Thank you so much for your time

-- 
Stefano


On 8 November 2010 00:23, Armisael <[email protected]> wrote:

> Thank you very much!
>
> Actually I think that what I need is a bit more complicated.
>
> I have basically some (hundreds) points, with some values associated (some
> kind of "impact" metrics). What I need is a raster to show the area affected
> by the points, depending on their impact and maybe (but I'm not sure yet)
> other information like altitude or population.
>
> My idea was to write a script and calculate the impact for each pixel, and
> then create the raster. But I was wondering if there is already something
> for doing it, or at least an example in python/C++ for it.
>
> Thank you!
>
> --
> Stefano
>
>
>
> On 4 November 2010 03:12, Simone Giannecchini <
> [email protected]> wrote:
>
>> here you go:
>>
>> http://www.gdal.org/gdal_rasterize.html
>>
>> Simone.
>> -------------------------------------------------------
>> ===
>> Notice that our office phone number has recently changed!
>> Please, update your records!
>> ===
>> Ing. Simone Giannecchini
>> GeoSolutions S.A.S.
>> Founder
>> Via Poggio alle Viti 1187
>> 55054  Massarosa (LU)
>> Italy
>>
>> phone: +39 0584962313
>> fax:      +39 0584962313
>> mob:    +39 333 8128928
>>
>>
>> http://www.geo-solutions.it
>> http://geo-solutions.blogspot.com/
>> http://www.linkedin.com/in/simonegiannecchini
>> http://twitter.com/simogeo
>>
>> -------------------------------------------------------
>>
>>
>>
>> On Wed, Nov 3, 2010 at 9:06 PM, Armisael <[email protected]>
>> wrote:
>> > Ciao Simone,
>> > thanks for your reply!
>> > I solved the problem just scaling each tile from 0 to 65535 using
>> > gdal_translate, but now that I read your post it's perfectly clear why I
>> had
>> > that result, and how to solve the problem in a proper way... Thank you!
>> > The next step will be to try to create a raster from a vector, let see
>> what
>> > I can do =)
>> > Grazie ancora!
>> > --
>> > Stefano
>> >
>> >
>> > On 3 November 2010 08:41, Simone Giannecchini
>> > <[email protected]> wrote:
>> >>
>> >> Ciao Stefano,
>> >> please read below...
>> >> -------------------------------------------------------
>> >> ===
>> >> Notice that our office phone number has recently changed!
>> >> Please, update your records!
>> >> ===
>> >> Ing. Simone Giannecchini
>> >> GeoSolutions S.A.S.
>> >> Founder
>> >> Via Poggio alle Viti 1187
>> >> 55054  Massarosa (LU)
>> >> Italy
>> >>
>> >> phone: +39 0584962313
>> >> fax:      +39 0584962313
>> >> mob:    +39 333 8128928
>> >>
>> >>
>> >> http://www.geo-solutions.it
>> >> http://geo-solutions.blogspot.com/
>> >> http://www.linkedin.com/in/simonegiannecchini
>> >> http://twitter.com/simogeo
>> >>
>> >> -------------------------------------------------------
>> >>
>> >>
>> >>
>> >> On Wed, Oct 20, 2010 at 5:27 PM, Armisael <[email protected]>
>> >> wrote:
>> >> > Ok, some update,
>> >> >
>> >> > thanks to you now I can see my DTED level 0! But there is a (little?)
>> >> > problem: it seems that in the resulting image the tiles are not
>> >> > correctly merged, since every single tile has its own color range, so
>> >> > at the borders there is a marked difference. This happen with all the
>> >> > methods I tried:
>> >> > - using gdal_merge.py to merge all the tiles directly from the dt0
>> >> > files;
>> >> > - using gdal_translate to create a tiff for every dt0 file and then
>> >> > merging them with gdal_merge.py;
>> >> > - using the imagemosaic plugin on the 414 small tiffs created from
>> the
>> >> > dt0 files.
>> >> >
>> >> > Note that gdal_translate called with param "-expand rgb" (just for
>> >> > testing) gave me "Error : band 1 has no color table".
>> >>
>> >> The dted is single band raw data (16 bits) I don't see how a color
>> >> expansion would work on this data. It needs
>> >> a colormapped imagery.
>> >>
>> >> > Note also that the generated geotiff appears completely black, the
>> >> > only way to see the DTED is to open it using geoserver, or to
>> increase
>> >> > the contrast using an image editor... So the file is correctly
>> >> > created, but something wrong happens on the color interval used,
>> >> > probably.
>> >>
>> >> Again, I see a little confisione here. DTED data is not a picture is
>> >> elevation data on 16 bits, therefore if you try to visualize it
>> >> directly you should see all black since
>> >> the heighest point on the eart is less than 9000 while the maximum
>> >> value allowed by 16 bits is much bigger, therefore the dynamic of the
>> >> data is compressed towards zero (black).
>> >>
>> >>
>> >> Here is what you need to do:
>> >>
>> >> -1- try to merge the data into larget geotiff + add overviews
>> >> -2- use a proper style, you can find some more info here:
>> >> http://blog.geoserver.org/2008/11/20/raster-symbolizer-tricks-part-1/
>> >>
>> >>
>> >> Ciao,
>> >> Simone.
>> >>
>> >>
>> >>
>> >> >
>> >> > Thank you!
>> >> >
>> >> > --
>> >> > Stefano
>> >> >
>> >> >
>> >> >
>> >> > On 19 October 2010 22:42, Armisael <[email protected]> wrote:
>> >> >> Thank you for your suggestion, if I've understood correctly I
>> should:
>> >> >> - convert all the tiles in geotiff
>> >> >> - merge them into larger geotiff if needed
>> >> >> - create an index file (shapefile) for the ImageMosaic plugin and
>> >> >> configure it in geoserver
>> >> >>
>> >> >> I'm developing a webgis for an humanitarian organization working in
>> >> >> Zambia, right now I'm trying to load generic data like boundaries,
>> >> >> cities, interesting location and DTED, then I'll have to create new
>> >> >> vector and raster layers from their database...
>> >> >>
>> >> >> I'll let you know!
>> >> >>
>> >> >> Thanks again
>> >> >>
>> >> >> --
>> >> >> Stefano
>> >> >>
>> >> >>
>> >> >>
>> >> >> On 18 October 2010 03:50, Simone Giannecchini
>> >> >> <[email protected]> wrote:
>> >> >>> I would also add this:
>> >> >>>
>> >> >>> - create a script using gdal traslate and convert them to geotiff
>> >> >>> - merge the single files, in case they are small into larger
>> geotiff
>> >> >>> files.
>> >> >>>
>> >> >>> Aside, can you tell us something about what you are doing with
>> >> >>> GeoServer?
>> >> >>> Simone.
>> >> >>> -------------------------------------------------------
>> >> >>> ===
>> >> >>> Notice that our office phone number has recently changed!
>> >> >>> Please, update your records!
>> >> >>> ===
>> >> >>> Ing. Simone Giannecchini
>> >> >>> GeoSolutions S.A.S.
>> >> >>> Founder
>> >> >>> Via Poggio alle Viti 1187
>> >> >>> 55054  Massarosa (LU)
>> >> >>> Italy
>> >> >>>
>> >> >>> phone: +39 0584962313
>> >> >>> fax:      +39 0584962313
>> >> >>> mob:    +39 333 8128928
>> >> >>>
>> >> >>>
>> >> >>> http://www.geo-solutions.it
>> >> >>> http://geo-solutions.blogspot.com/
>> >> >>> http://www.linkedin.com/in/simonegiannecchini
>> >> >>> http://twitter.com/simogeo
>> >> >>>
>> >> >>> -------------------------------------------------------
>> >> >>>
>> >> >>>
>> >> >>>
>> >> >>> On Mon, Oct 18, 2010 at 8:34 AM, Andrea Aime
>> >> >>> <[email protected]> wrote:
>> >> >>>> On Mon, Oct 18, 2010 at 5:20 AM, Armisael <
>> [email protected]>
>> >> >>>> wrote:
>> >> >>>>> OK, it seems that I have to insert the dt0 file in order to
>> create
>> >> >>>>> the
>> >> >>>>> store, and it works!
>> >> >>>>> Not, the point is that I have 414 dt0 files! Do I really have to
>> >> >>>>> create a store for each of them?
>> >> >>>>> Do you know if there is something more appropriate for this task?
>> Or
>> >> >>>>> at least if there is an automatic way to do it?
>> >> >>>>
>> >> >>>> Many files. Are they tiles of the same seamless data set?
>> >> >>>> If so, put all of them in the same directory and point the image
>> >> >>>> mosaic plugin
>> >> >>>> to it.
>> >> >>>> Otherwise you can use the REST config extension and create a
>> script
>> >> >>>> to import
>> >> >>>> them all with your preferred scripting language
>> >> >>>>
>> >> >>>> Cheers
>> >> >>>> Andrea
>> >> >>>>
>> >> >>>> -----------------------------------------------------
>> >> >>>> Ing. Andrea Aime
>> >> >>>> Senior Software Engineer
>> >> >>>>
>> >> >>>> GeoSolutions S.A.S.
>> >> >>>> Via Poggio alle Viti 1187
>> >> >>>> 55054  Massarosa (LU)
>> >> >>>> Italy
>> >> >>>>
>> >> >>>> phone: +39 0584962313
>> >> >>>> fax:     +39 0584962313
>> >> >>>>
>> >> >>>> http://www.geo-solutions.it
>> >> >>>> http://geo-solutions.blogspot.com/
>> >> >>>> http://www.linkedin.com/in/andreaaime
>> >> >>>> http://twitter.com/geowolf
>> >> >>>>
>> >> >>>> -----------------------------------------------------
>> >> >>>>
>> >> >>>>
>> >> >>>>
>> ------------------------------------------------------------------------------
>> >> >>>> Download new Adobe(R) Flash(R) Builder(TM) 4
>> >> >>>> The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
>> >> >>>> Flex(R) Builder(TM)) enable the development of rich applications
>> that
>> >> >>>> run
>> >> >>>> across multiple browsers and platforms. Download your free trials
>> >> >>>> today!
>> >> >>>> http://p.sf.net/sfu/adobe-dev2dev
>> >> >>>> _______________________________________________
>> >> >>>> Geoserver-users mailing list
>> >> >>>> [email protected]
>> >> >>>> https://lists.sourceforge.net/lists/listinfo/geoserver-users
>> >> >>>>
>> >> >>>
>> >> >>
>> >> >
>> >> >
>> >> >
>> ------------------------------------------------------------------------------
>> >> > Nokia and AT&T present the 2010 Calling All Innovators-North America
>> >> > contest
>> >> > Create new apps & games for the Nokia N8 for consumers in  U.S. and
>> >> > Canada
>> >> > $10 million total in prizes - $4M cash, 500 devices, nearly $6M in
>> >> > marketing
>> >> > Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi
>> Store
>> >> > http://p.sf.net/sfu/nokia-dev2dev
>> >> > _______________________________________________
>> >> > Geoserver-users mailing list
>> >> > [email protected]
>> >> > https://lists.sourceforge.net/lists/listinfo/geoserver-users
>> >> >
>> >
>> >
>>
>
>
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper
David G. Thomson, author of the best-selling book "Blueprint to a 
Billion" shares his insights and actions to help propel your 
business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Geoserver-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geoserver-users

Reply via email to