Can't create PNG file with “st_png” function PostGIS and Java Unicorn Meta Zoo #1: Why...

std::is_constructible on incomplete types

Can you stand up from being prone using Skirmisher outside of your turn?

Where did Arya get these scars?

Married in secret, can marital status in passport be changed at a later date?

Putting Ant-Man on house arrest

My bank got bought out, am I now going to have to start filing tax returns in a different state?

Has a Nobel Peace laureate ever been accused of war crimes?

Is Diceware more secure than a long passphrase?

Multiple options vs single option UI

What's the difference between using dependency injection with a container and using a service locator?

Split coins into combinations of different denominations

Does the set of sets which are elements of every set exist?

Why is this method for solving linear equations systems using determinants works?

Can I criticise the more senior developers around me for not writing clean code?

Map material from china not allowed to leave the country

How do I check if a string is entirely made of the same substring?

Will I lose my paid in full property

What's parked in Mil Moscow helicopter plant?

What is this word supposed to be?

How to open locks without disable device?

Dynamic Return Type

Is it acceptable to use working hours to read general interest books?

Is there any hidden 'W' sound after 'comment' in : Comment est-elle?

Refugee travel document from Spain to US



Can't create PNG file with “st_png” function PostGIS and Java



Unicorn Meta Zoo #1: Why another podcast?
Announcing the arrival of Valued Associate #679: Cesar ManaraCreate GeoTIFF from TIFF using JavaJava shared hosting with PostGISUpdate Service config file with ArcIms java connectorRetrieving info from GRIB2 file with JAVA?Converting WKT to WKB in Java using PostGIS?Create shapefile from data postgis / kml using javaCreate shapefile from data PostGIS or KML using JavaCreate compressed GeoTiff in JavaCreate shapefile based on geojson data with geotools (Java)Java GeoTools read VRT file





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







1















I have this code in Java:



conn = DriverManager.getConnection ("jdbc: postgresql: // localhost: 5432 / postgis_23_sample" "postgres", "admin");

conn.setAutoCommit (false);

String s = "SELECT ST_AsRaster (ST_Buffer (ST_GeomFromText ('LINESTRING (50 50,150 150,150 50)'), 10), 200,200, ARRAY ['8BUI' '8BUI' '8BUI'] ARRAY [118,154,118] ARRAY [0 , 0,0]) ";

PreparedStatement sGetImg = conn.prepareStatement (s);
SGetImg.executeQuery ResultSet rs = ();
FileOutputStream fout;

try
{

rs.next ();
fout = new FileOutputStream (new File ("d: \ files \ save1x.png"));
fout.write (rs.getBytes (1));
fout.close ();

}

catch (Exception e)
{

System.out.println ("Can not create file");
e.printStackTrace ();

}

rs.close ();
sGetImg.close ();
conn.close ();

catch (SQLException se)
{

System.out.println ("Could not connect: print out a stack trace and exit.");
se.printStackTrace ();
System.exit (1);

}

....


I created the file but apparently the PNG file is corrupt, you can not open. That I can be doing wrong.



I reviewed the bytes and the query returns the array of bytes me, but does not write the file apparently well.



Postgres 9.4 y PosGis 2.2










share|improve this question
















bumped to the homepage by Community 28 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Is there a purpose to the extra spaces in all your path strings?

    – Vince
    Jan 14 '16 at 16:41


















1















I have this code in Java:



conn = DriverManager.getConnection ("jdbc: postgresql: // localhost: 5432 / postgis_23_sample" "postgres", "admin");

conn.setAutoCommit (false);

String s = "SELECT ST_AsRaster (ST_Buffer (ST_GeomFromText ('LINESTRING (50 50,150 150,150 50)'), 10), 200,200, ARRAY ['8BUI' '8BUI' '8BUI'] ARRAY [118,154,118] ARRAY [0 , 0,0]) ";

PreparedStatement sGetImg = conn.prepareStatement (s);
SGetImg.executeQuery ResultSet rs = ();
FileOutputStream fout;

try
{

rs.next ();
fout = new FileOutputStream (new File ("d: \ files \ save1x.png"));
fout.write (rs.getBytes (1));
fout.close ();

}

catch (Exception e)
{

System.out.println ("Can not create file");
e.printStackTrace ();

}

rs.close ();
sGetImg.close ();
conn.close ();

catch (SQLException se)
{

System.out.println ("Could not connect: print out a stack trace and exit.");
se.printStackTrace ();
System.exit (1);

}

....


I created the file but apparently the PNG file is corrupt, you can not open. That I can be doing wrong.



I reviewed the bytes and the query returns the array of bytes me, but does not write the file apparently well.



Postgres 9.4 y PosGis 2.2










share|improve this question
















bumped to the homepage by Community 28 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • Is there a purpose to the extra spaces in all your path strings?

    – Vince
    Jan 14 '16 at 16:41














1












1








1








I have this code in Java:



conn = DriverManager.getConnection ("jdbc: postgresql: // localhost: 5432 / postgis_23_sample" "postgres", "admin");

conn.setAutoCommit (false);

String s = "SELECT ST_AsRaster (ST_Buffer (ST_GeomFromText ('LINESTRING (50 50,150 150,150 50)'), 10), 200,200, ARRAY ['8BUI' '8BUI' '8BUI'] ARRAY [118,154,118] ARRAY [0 , 0,0]) ";

PreparedStatement sGetImg = conn.prepareStatement (s);
SGetImg.executeQuery ResultSet rs = ();
FileOutputStream fout;

try
{

rs.next ();
fout = new FileOutputStream (new File ("d: \ files \ save1x.png"));
fout.write (rs.getBytes (1));
fout.close ();

}

catch (Exception e)
{

System.out.println ("Can not create file");
e.printStackTrace ();

}

rs.close ();
sGetImg.close ();
conn.close ();

catch (SQLException se)
{

System.out.println ("Could not connect: print out a stack trace and exit.");
se.printStackTrace ();
System.exit (1);

}

....


I created the file but apparently the PNG file is corrupt, you can not open. That I can be doing wrong.



I reviewed the bytes and the query returns the array of bytes me, but does not write the file apparently well.



Postgres 9.4 y PosGis 2.2










share|improve this question
















I have this code in Java:



conn = DriverManager.getConnection ("jdbc: postgresql: // localhost: 5432 / postgis_23_sample" "postgres", "admin");

conn.setAutoCommit (false);

String s = "SELECT ST_AsRaster (ST_Buffer (ST_GeomFromText ('LINESTRING (50 50,150 150,150 50)'), 10), 200,200, ARRAY ['8BUI' '8BUI' '8BUI'] ARRAY [118,154,118] ARRAY [0 , 0,0]) ";

PreparedStatement sGetImg = conn.prepareStatement (s);
SGetImg.executeQuery ResultSet rs = ();
FileOutputStream fout;

try
{

rs.next ();
fout = new FileOutputStream (new File ("d: \ files \ save1x.png"));
fout.write (rs.getBytes (1));
fout.close ();

}

catch (Exception e)
{

System.out.println ("Can not create file");
e.printStackTrace ();

}

rs.close ();
sGetImg.close ();
conn.close ();

catch (SQLException se)
{

System.out.println ("Could not connect: print out a stack trace and exit.");
se.printStackTrace ();
System.exit (1);

}

....


I created the file but apparently the PNG file is corrupt, you can not open. That I can be doing wrong.



I reviewed the bytes and the query returns the array of bytes me, but does not write the file apparently well.



Postgres 9.4 y PosGis 2.2







postgis java






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 14 '16 at 18:13









Vince

14.8k32850




14.8k32850










asked Jan 14 '16 at 15:37









Carlos Alberto Rojas CasiqueCarlos Alberto Rojas Casique

113




113





bumped to the homepage by Community 28 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 28 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • Is there a purpose to the extra spaces in all your path strings?

    – Vince
    Jan 14 '16 at 16:41



















  • Is there a purpose to the extra spaces in all your path strings?

    – Vince
    Jan 14 '16 at 16:41

















Is there a purpose to the extra spaces in all your path strings?

– Vince
Jan 14 '16 at 16:41





Is there a purpose to the extra spaces in all your path strings?

– Vince
Jan 14 '16 at 16:41










1 Answer
1






active

oldest

votes


















0














Based on my reading of the documentation shouldn't your query be



SELECT ST_AsPNG(ST_AsRaster (ST_Buffer (ST_GeomFromText ('LINESTRING (50 50,150 150,150 50)'), 10), 200,200, ARRAY ['8BUI' '8BUI' '8BUI'] ARRAY [118,154,118] ARRAY [0 , 0,0]));





share|improve this answer
























  • sorry el string sql is : SELECT ST_AsPNG(ST_AsRaster(ST_Buffer(ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'), 10,'join=bevel'),200,200,ARRAY['8BUI', '8BUI', '8BUI'], ARRAY[118,154,118], ARRAY[0,0,0]));

    – Carlos Alberto Rojas Casique
    Jan 14 '16 at 18:44












Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "79"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f176867%2fcant-create-png-file-with-st-png-function-postgis-and-java%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Based on my reading of the documentation shouldn't your query be



SELECT ST_AsPNG(ST_AsRaster (ST_Buffer (ST_GeomFromText ('LINESTRING (50 50,150 150,150 50)'), 10), 200,200, ARRAY ['8BUI' '8BUI' '8BUI'] ARRAY [118,154,118] ARRAY [0 , 0,0]));





share|improve this answer
























  • sorry el string sql is : SELECT ST_AsPNG(ST_AsRaster(ST_Buffer(ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'), 10,'join=bevel'),200,200,ARRAY['8BUI', '8BUI', '8BUI'], ARRAY[118,154,118], ARRAY[0,0,0]));

    – Carlos Alberto Rojas Casique
    Jan 14 '16 at 18:44
















0














Based on my reading of the documentation shouldn't your query be



SELECT ST_AsPNG(ST_AsRaster (ST_Buffer (ST_GeomFromText ('LINESTRING (50 50,150 150,150 50)'), 10), 200,200, ARRAY ['8BUI' '8BUI' '8BUI'] ARRAY [118,154,118] ARRAY [0 , 0,0]));





share|improve this answer
























  • sorry el string sql is : SELECT ST_AsPNG(ST_AsRaster(ST_Buffer(ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'), 10,'join=bevel'),200,200,ARRAY['8BUI', '8BUI', '8BUI'], ARRAY[118,154,118], ARRAY[0,0,0]));

    – Carlos Alberto Rojas Casique
    Jan 14 '16 at 18:44














0












0








0







Based on my reading of the documentation shouldn't your query be



SELECT ST_AsPNG(ST_AsRaster (ST_Buffer (ST_GeomFromText ('LINESTRING (50 50,150 150,150 50)'), 10), 200,200, ARRAY ['8BUI' '8BUI' '8BUI'] ARRAY [118,154,118] ARRAY [0 , 0,0]));





share|improve this answer













Based on my reading of the documentation shouldn't your query be



SELECT ST_AsPNG(ST_AsRaster (ST_Buffer (ST_GeomFromText ('LINESTRING (50 50,150 150,150 50)'), 10), 200,200, ARRAY ['8BUI' '8BUI' '8BUI'] ARRAY [118,154,118] ARRAY [0 , 0,0]));






share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 14 '16 at 18:11









Ian TurtonIan Turton

50.5k548120




50.5k548120













  • sorry el string sql is : SELECT ST_AsPNG(ST_AsRaster(ST_Buffer(ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'), 10,'join=bevel'),200,200,ARRAY['8BUI', '8BUI', '8BUI'], ARRAY[118,154,118], ARRAY[0,0,0]));

    – Carlos Alberto Rojas Casique
    Jan 14 '16 at 18:44



















  • sorry el string sql is : SELECT ST_AsPNG(ST_AsRaster(ST_Buffer(ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'), 10,'join=bevel'),200,200,ARRAY['8BUI', '8BUI', '8BUI'], ARRAY[118,154,118], ARRAY[0,0,0]));

    – Carlos Alberto Rojas Casique
    Jan 14 '16 at 18:44

















sorry el string sql is : SELECT ST_AsPNG(ST_AsRaster(ST_Buffer(ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'), 10,'join=bevel'),200,200,ARRAY['8BUI', '8BUI', '8BUI'], ARRAY[118,154,118], ARRAY[0,0,0]));

– Carlos Alberto Rojas Casique
Jan 14 '16 at 18:44





sorry el string sql is : SELECT ST_AsPNG(ST_AsRaster(ST_Buffer(ST_GeomFromText('LINESTRING(50 50,150 150,150 50)'), 10,'join=bevel'),200,200,ARRAY['8BUI', '8BUI', '8BUI'], ARRAY[118,154,118], ARRAY[0,0,0]));

– Carlos Alberto Rojas Casique
Jan 14 '16 at 18:44


















draft saved

draft discarded




















































Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f176867%2fcant-create-png-file-with-st-png-function-postgis-and-java%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

(145452) 2005 RN43 Классификация | Примечания | Ссылки |...

Щит и меч (фильм) Содержание Названия серий | Сюжет |...

Энтрерриос (город) Содержание История | Географическое...