Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you help me write a python code with the assignment below? Flood map from lab 4. We can use this data to make a

Can you help me write a python code with the assignment below?

Flood map from lab 4.

We can use this data to make a flood map of New York City. When Hurricane Sandy hit New York City in 2012, sea level rose 6 feet above normal, causing extensive flooding in low lying areas (NYT map). For our flood map, we can incorporate the storm surge into our coloring scheme:

 if elevation  

To give us complete control of the coloring, we will create a new array that will hold the colors for each pixel. Here's an outline of our program:

  1. Import the libraries to manipulate and display arrays.
  2. Read in the NYC data and store in the variable, elevations
  3. Create a new array, floodMap, to hold our colors for the map.
  4. For each element in elevations, make a pixel colored by the schema above.
  5. Load our image into pyplot.
  6. Display the image.

We'll use a very simple (but a bit garish) color scheme, with our "blue" being 0% red, 0% green, and 100% blue. And similarly, the "red" and the "green" we'll use will be 100% of each, 0% of the others, giving a map like:

image text in transcribed

Here's the code, implementing our outline below. Copy it into an IDLE window and run it. It expects that the file elevationsNYC.txt is in the same directory as your program.

# Name: ... your name here ... # Date: September 2017 # Takes elevation data of NYC and displays using the default color map #Import the libraries for arrays and displaying images: import numpy as np import matplotlib.pyplot as plt #Read in the data to an array, called elevations: elevations = np.loadtxt('elevationsNYC.txt') #Take the shape (dimensions) of the elevations # and add another dimension to hold the 3 color channels: mapShape = elevations.shape + (3,) #Create a blank image that's all zeros: floodMap = np.zeros(mapShape) for row in range(mapShape[0]): for col in range(mapShape[1]): if elevations[row,col]  

What would you change to make a more fine-grained map? Namely, modify your program to color the region just above the Sandy storm surge (6 feet) and less than or equal to 20 feet the color grey (50% red, 50% green, 50% blue). Also, modify your program to not show any graphics windows (plt.show()) but instead just compute and save the map to floodMap.png. See Programming Problem List.

Hello, I need help with this programming assignment below.

Modify the flood map of NYC from Lab 4 to color the region of the map with elevation greater than 6 feet and less than or equal 20 feet above sea level the color grey (50% red, 50% green, and 50% blue).

Your resulting map should look like:

image text in transcribed

and be saved to a file called floodMap.png.

Note: before submitting your program for grading, remove the commands that show the image (i.e. the ones that pop up the graphics window with the image). The program is graded on a server on the cloud and does not have a graphics window, so, the plt.show() and plt.show() commands will give an error. Instead, the files your program produces are compared pixel-by-pixel to the answer to check for correctness

100 300 400 100 200 300 400 100 200 300 400 100 200 300 400 100 300 400 100 200 300 400 100 200 300 400 100 200 300 400

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions