Author Topic: Clip Boundaries for a Raster  (Read 38665 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #45 on: November 15, 2007, 02:57:13 PM »
By selecting the lower left and upper right; we already have all the coords that we need
So again, it is just filling in

Code: [Select]
'Clip boundary = picked points (llpnt and urpnt)
 clipPoints(0) = llpnt(0): clipPoints(1) = llpnt(1)
 clipPoints(2) = llpnt(0): clipPoints(3) = urpnt(1)
 clipPoints(4) = urpnt(0): clipPoints(5) = urpnt(1)
 clipPoints(6) = urpnt(0): clipPoints(7) = llpnt(1)
 clipPoints(8) = llpnt(0): clipPoints(9) = llpnt(1)

with the proper coords

User inputs 10 x 10
We grab that and do 10 -/+ llpnt and urpnt to get the clip boundary, I think :)

I am loosing my ability to think at this point  :-(

Mark

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #46 on: November 15, 2007, 03:03:32 PM »


I think what we really need is VBAnonymous Meetings  LOL

Bob Wahr

  • Guest
Re: Clip Boundaries for a Raster
« Reply #47 on: November 15, 2007, 03:05:18 PM »
Beware the pseudocodiness of it
Code: [Select]
numbah = thisdrawing.utility.getreal ("How big a square ya after, Bucko?: ")

  clipPoints(0) = mdpnt(0) - numbah/2: clipPoints(1) = mdpnt(1) - numbah/2
  clipPoints(2) = mdpnt(0) - numbah/2: clipPoints(3) = mdpnt(1) + numbah/2
  clipPoints(4) = mdpnt(0) + numbah/2: clipPoints(5) = mdpnt(1) + numbah/2
  clipPoints(6) = mdpnt(0) + numbah/2: clipPoints(7) = mdpnt(1) - numbah/2
  clipPoints(8) = mdpnt(0) - numbah/2: clipPoints(9) = mdpnt(1) + -numbah/2

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #48 on: November 15, 2007, 03:08:33 PM »

Bob; if you keep this up; I will be asking for your phone number LOL; just kidding  :-D

Of course, now I need to go try this  :-)

Mark


Bob Wahr

  • Guest
Re: Clip Boundaries for a Raster
« Reply #49 on: November 15, 2007, 03:11:30 PM »

Bob; if you keep this up; I will be asking for your phone number LOL; just kidding  :-D

Of course, now I need to go try this  :-)

Mark


It's going to take some tweaking, that was just a nudge.  You'll need to bump up your error handling so that it knows what to do when somebody types in something that's not a number.  You might want to put in a default size so they can hit enter to get the default.  You might also want to give them an option to do a rectangle instead of square.  Then again, maybe not.

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #50 on: November 15, 2007, 03:13:02 PM »

That's funny; using the midpoint was my idea originally although I needed your guys help on how to build around it; however I failed to think of that in this (CM's idea) application.

I keep getting stuck on the upper and lower points.

The midpoint is definetely THE most logical place to work from.

So, Hats off to Bob again!  :-)

Mark

Maverick®

  • Seagull
  • Posts: 14778
Re: Clip Boundaries for a Raster
« Reply #51 on: November 15, 2007, 03:26:48 PM »
Bob; if you keep this up; I will be asking for your phone number

Like that hasn't been on how many bar napkins and toilet stalls west of the Mississippi.

Bob Wahr

  • Guest
Re: Clip Boundaries for a Raster
« Reply #52 on: November 15, 2007, 03:29:00 PM »
A couple of other thoughts to throw out to you.  with the two point selection method, you could just check the distance, round to the nearest whole number, and clip.  For a midpoint centered clip, you can just get them to pick a center point and distance instead of two points.

Bob Wahr

  • Guest
Re: Clip Boundaries for a Raster
« Reply #53 on: November 15, 2007, 03:29:38 PM »
Bob; if you keep this up; I will be asking for your phone number

Like that hasn't been on how many bar napkins and toilet stalls west of the Mississippi.
West of the Mississippi?  I've got national renown.

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #54 on: November 15, 2007, 03:29:51 PM »
WAIT!

Bob

With your code

Code: [Select]
numbah = thisdrawing.utility.getreal ("How big a square ya after, Bucko?: ")

  clipPoints(0) = mdpnt(0) - numbah/2: clipPoints(1) = mdpnt(1) - numbah/2
  clipPoints(2) = mdpnt(0) - numbah/2: clipPoints(3) = mdpnt(1) + numbah/2
  clipPoints(4) = mdpnt(0) + numbah/2: clipPoints(5) = mdpnt(1) + numbah/2
  clipPoints(6) = mdpnt(0) + numbah/2: clipPoints(7) = mdpnt(1) - numbah/2
  clipPoints(8) = mdpnt(0) - numbah/2: clipPoints(9) = mdpnt(1) + -numbah/2

We will still need

Code: [Select]
Dim llpnt As Variant 'lower left point
Dim urpnt As Variant 'upper right point
Dim mdpnt(0 To 2) As Double
Dim clipPoints(0 To 9) As Double
      
With ThisDrawing.Utility
 llpnt = .GetPoint(, vbCrLf & "Select Lower Left Point: ")
 urpnt = .GetPoint(, vbCrLf & "Select Upper Right Point: ")
End With
  
mdpnt(0) = (llpnt(0) + urpnt(0)) / 2 'Midpoint (X) = (The far left picked point + the far right picked point) / 2
mdpnt(1) = (llpnt(1) + urpnt(1)) / 2 'Midpoint (Y) = (The far bottom picked point + the far top picked point) / 2
mdpnt(2) = 0

To get our midpoint; based off of the picked points in the above code, correct?

So, we get our picked points, figure out the midpnt (all done), then with Bob's "new" code, we get the boundary size;
the boundary size gets divided by 2 and gets built around the midpoint in all 4 directions at that (the divided) size
Very clever!

Mark

Mark

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: Clip Boundaries for a Raster
« Reply #55 on: November 15, 2007, 03:35:04 PM »
Bob is on the right track of what I was thinking.  Bob, how do you do the default thing???  In LISP I know you use <> to define it, but I never learned how in VBA
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

Bob Wahr

  • Guest
Re: Clip Boundaries for a Raster
« Reply #56 on: November 15, 2007, 03:35:39 PM »
Did everyone hear the click as the pieces fell into place?

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #57 on: November 15, 2007, 03:36:12 PM »

Bob

Thankfully, I don't swing that way, but I will work for code  :-D


Also, your above idea is also very clever.
Pick center point and get size.


Mark


Bob Wahr

  • Guest
Re: Clip Boundaries for a Raster
« Reply #58 on: November 15, 2007, 03:37:58 PM »
Bob is on the right track of what I was thinking.  Bob, how do you do the default thing???  In LISP I know you use <> to define it, but I never learned how in VBA
You use error handling with VBA I throw the <crap> into my prompt so it looks familiar to Johnny Caduserguy but it's handle with the error trapping.

ML

  • Guest
Re: Clip Boundaries for a Raster
« Reply #59 on: November 15, 2007, 03:38:27 PM »

Quote
Did everyone hear the click as the pieces fell into place?

I'm sorry I must have missed it but I hear the click in my e-mail every time there is a new post  :-)